Matching IDs preceded with "case" with SSIS script using C# regex -


i using ssis script component extract information string.

i id in string in below pattern: case:123455

it embedded in string below:

this string. want case:12345 , case:5656759 in title 2. 

i extract id 12345 & 565675 string. occurrence of 'case' dynamic, can none, can appear 1 or more 1 in string. need regex syntax extract info.

the following cases should captured :

case:12345, case :12345, case: 12345, case : 12345, case:12345, case:12345 

you can make use of look-behind , \d+:

(?i)(?<=\bcase:)\d+ 

see demo

this regex match 1 or more digits appear after literal string case: case whole word.

in case need version capturing group, here is:

(?i)\bcase:(\d+) 

the value need stored in capturing group 1.

update

to allow optional spaces in pattern, use either

(?i)(?<=\bcase\s*:\s*)\d+ 

or version without lookbehind:

(?i)\bcase\s*:\s*(\d+)     

making pattern case-insensitive

the (?i) inline option/flag makes pattern case-insensitive, match case , case. if want match case , case , case, need use (?:[cc]ase|case).


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -