Using sentence with Matches activity

studio
regex

#1

Hi all

I’m using Matches activity to get a word between two sentences. All works fine if the LabelBefore and LabelAfter doesn’t have an space inside them (something like “textBefore” and “textAfter”). I need to assign this variables a text that have a space, something like LabelBefore = “spaced text 1” and LabelAfter=“Spaced text 2” but when I do this the Matches activity says that not match was found. How can I solve this?
And if there’s no value, how can get it “Matches Result” as null and not the error that it’s not declared?

Regards,
J.


#2

Did you try checking “IgnorePatternWhiteSpace” in Regex Option?


#3

Yes, it shows the same error :frowning:


#4

Works for me. Is this you are trying to do? Try with default regex options only.

text : " text 1 helloworld text 2"

regex pattern : "(?<=text 1)(.*?)(?=text 2)"

#5
options = RegexOptions.IgnorePatternWhitespace;
reWorks       = new Regex(@"(?<a>)", options);
reDoesNotWork = new Regex(@"( ?<a>)", options);

#6

Hi all

I tried it but it doesn’t work. Maybe it’s because my text is like this:

Test example 1
THIS is the text

regex pattern : “(?<=Test example 1)(.*?)(?=is the text)”

It says that is not match. The following regex options are activaded:
Multiline, IgnoreCase, IgnorePatternWhiteSpace.
What can I do?

Regards,
J.


#7

IgnoreCase,SingleLine

If any whitespace, you can add trim to your result.


#8

It doesn’t work. Says that not match has found. What else can I do? :S


#9

Matches.xaml (7.0 KB)


#10

It works for two lines but i have a case that nees to take 3 lines. How can I do this?


#11

Something that I can’t do is to get the data when the example is like this:

Test example 1
word before THIS the text

I want to get THIS but it doesn’t work. This is my pattern:

"(?<=Test example 1 word before)(.*?)(?=the text)"
Options: IgnoreCase, IgnorePatternWhiteSpace

What can I do?