Regex Multiline Not Matching

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!

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

Hi @Caleb_D2

Try like this

Hope this helps!!

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)

Hi,

It may be linebreak matter. Can you try the following pattern?

(?<=CSD\r?\n.+?)\d+

Regards,

@Caleb_D2

Please find the below xaml

BlankProcess13.zip (41.5 KB)

Cheers!!

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

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!!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.