Why not debug..my regex RPA

I try to extract the language between specific characters.

For example, [a. Suitable Extinguishing Media
Dry powder dry sand
Extinguishing media not to be used for safety reasons
Do not use water spray.
b. Specific hazards arising from the chemical]

[Powder extinguishing dry sand
Extinguishing media not to be used for safety reasons
Don’t use water spray.] So I read the read pdf text and give it an assign activity and then try to get the result as a log message. Assign: Object reference not set to an instance of an object. It happens. Help me (I’ll give you a pdf and an rpa file)266558_SIGMA.pdf (239.1 KB) BlankProcess (2).zip (15.2 KB)

Are you sure the pattern you’re searching for is present in the string variable?

You may need to do an if statement to verify that your pattern is actually in the string before extracting the value:

IF statement (put your extraction in the false portion in this case) =

String.IsNullOrEmpty(Regex.Match(StringVariable,“RegexPatternHere”,RegexOptions.IgnoreCase).Value)

The pattern I use to extract values between two words is:

(?<=WordOne).+(?=WordTwo)

1 Like

“(? <=” + sStart + “) (… *?) (? =” + sEnd + “)” Why not?