Syman
(Simon)
1
Hallo Community,
does anybody know if Robotframework Core does support Regex with the non-capturing group syntax.
Example:
(?: # some regex expression )
I used a regex construct but it did not work unless I removed the “?:” above.
Does anybody know how to escape this expression?
Hi,
I can tell you that I have some fields and Regex likes this that works well:
VAR ${period} From dd/mm/yyyy at hh:mm to dd/mm/yyyy at hh:mm
${end} Get Regexp Matches ${period} (?<=to )\\d{2}/\\d{2}/\\d{4} at \\d{2}:\\d{2}
Or this:
VAR ${maildata} Your temporary code is:1a2b
${code} Get Regexp Matches ${maildata} (?<=Your temporary code is:)(\\w+)
And this get me the intended value (end date-time) or code to work with.
Hope this helps.
Regards.
Charlie
1 Like
bhagwatn
(Narendra Bhagwat)
4
How to specify multiple non capturing groups? Are more than one non capturing groups supported?
e.g.
(?<=skip this #1)(capture this)(?<=skip this #2)
${Match} Get Regexp Matches ${line} (?<=:\\s)([\\w]+)(?<=\\sis)
#line = : Hello is
#I want to capture "Hello" while mentioning that ignore the \\sis
Thanks,
Narendra Bhagwat
Hi,
In this case you should use both Lookbehind (?<=caracters) and Lookeahead (?=caracters):
Standard regex expression:
(?<=:\s)[\w]+(?=\sis)
So here you’re searching for a string with letters/numbers, that has behind/before : and ahead/after is
RF escaped regex expression:
VAR ${string} : Hello is
${result} Get Regexp Matches ${string} (?<=:\\s)[\\w]+(?=\\sis)
As another example if you need multiple groups/non-capturing groups, you could use something like this to get ‘Hello’ and ‘Goodbye’:
: Hello is not Goodbye
Regex :
(?<=:\s)[\w]+(?=\sis)|(?<=not\s)[\w]+
Here you’ll get in RF a result variable as a list with two items:

Regards.
Charlie