Caleb_D2
(Caleb D)
October 10, 2023, 2:08pm
1
I have the following string:
County: Clinton County: Greene
[code: 027] [code: 057]
School District: Wilmington CSD School District: Xenia Community CSD
[code: 1404] [code: 2906]
City: Wilmington City: Xenia
[code: 1061792, FIPS code: 85792]
I’m wanting to find the line following “CSD” and retrieve the 2 numeric codes found there. So in my example string, that would be ‘1404 ’ and ‘2906 ’.
I have the following Regex expression that works in the Regex site regexr.com but not in Studio:
(?<=CSD\n.+)\d+
Having looked at other forum posts, I am using the Matches activity with the Multiline option enabled .
Any help would be greatly appreciated!
supriya117
(Supriya Allada)
October 10, 2023, 2:13pm
2
Hi @Caleb_D2
Try this:
(?<=CSD\s*.+)\d+
No need to enable multiline option. Sometimes \n
didn’t work in studio. So try to avoid with \s*
1 Like
Gokul001
(Gokul Balaji)
October 10, 2023, 2:17pm
4
HI @Caleb_D2
Try with this Regular Expression
System.Text.RegularExpressions.Regex.Match(YourString,"(?<Code1>(?<=CSD\n\Wcode:\s)\d+)\W\s\Wcode\W\s(?<Code2>\d+)").Groups(1)
Yoichi
(Yoichi)
October 10, 2023, 2:18pm
5
Hi,
It may be linebreak matter. Can you try the following pattern?
(?<=CSD\r?\n.+?)\d+
Regards,
lrtetala
(Lakshman Reddy)
October 10, 2023, 2:18pm
6
@Caleb_D2
Please find the below xaml
BlankProcess13.zip (41.5 KB)
Cheers!!
Caleb_D2
(Caleb D)
October 10, 2023, 2:20pm
7
Wow, lots of great replies! Thanks everyone for looking into this. I marked the response from @supriya117 as the solution as this is the simplest one. Now I know to try and avoid using \n and use \s instead.
1 Like
Parvathy
(PS Parvathy)
October 10, 2023, 2:20pm
8
Hi @Caleb_D2
Input: "County: Clinton County: Greene
[code: 027] [code: 057]
School District: Wilmington CSD School District: Xenia Community CSD
[code: 1404] [code: 2906]
City: Wilmington City: Xenia
[code: 1061792, FIPS code: 85792]"
=> Use Find Matching Patterns acitvity and give as details as per below image:
Pattern: "(?<=CSD\n.+)\d+"
Pattern Options: Multiline, Compiled
Text to Search In: Input
Result: Output(Create a variable)
=> Run a For Each loop to iterate through Output variable and print the output in Writeline or Message Box, Log Message.
Refer the workflow for better understanding
Sequence6.xaml (7.5 KB)
Hope it helps!!
system
(system)
Closed
October 13, 2023, 2:21pm
9
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.