Text Actions - RegEx help

Hello,

I have the following business case:
I load an excel sheet containing two columns (email and subject) in a table.
When I receive an email I need to check

  1. If the sender exists in the table
  2. If the subject related to the sender has the correct format
    Then I can move on.

The problem is with the subject comparison. The pattern (loaded from the excel to the table) is like
’My name is Dimitrios and I try to make it work’
The email subject may contain anything instead of Dimitrios, but must start and end with the same way as the pattern.
One more thing: The pattern is not the same, there are different patterns in the table and I need to check every email against all of them.

My thought is that changing the excel structure containing 3 columns (email, start pattern, end pattern) and checking the if email subject starts with and end with those patterns will make my life easier, but I know almost nothing about RegEx.

Is there a way to use Text actions in combination with RegEx to achieve this easier and faster?

Any input/ideas is much appreciated.

Kind regards,
Dimitrios

Hi Dimitrios,
Try using this expression for the pattern “My name is Dimitrios and I try to make it work”:

^My name is .*and I try to make it work$

You can use it for other patterns, just change the text at the beginning of the string (^My name is .*) and the end of the string (and I try to make it work$).

1 Like

Hello @ashapkina ,

This works with the 'My name is ’ and ‘and I try to make it work’ parts pre-defined.
What if those parts exist in variables? How can I use the variables inside this RegEx?

Kind regards,
Dimitrios

You can define the RegEx through Constant Value action as shown below and then use the RegEx value in the condition.
Keep in mind that you cannot use the dollar sign ($) in the expression, so you should put it in a string variable, too, and use the variable.

1 Like

Many thanks for the quick answer!
I believe this is what I need. I will try it and write back with the outcome

Hello again,

I managed to make it work the way you suggested. I also added the ignore case start and end as variables and use them when I am joining the strings.
All looks good!

Many thanks again,
Dimitrios

1 Like

Great! :+1:t3:

Sorry to open that one again, but all of a sudden the ignore case stopped working.
I have my regex in a variable (regex), the start of ignore case in another (regexignorestart = ‘/’) and the end in a third one (regexignoreend = ‘/i’).
So, I use a Join as:
regexignorestart
regex
regexignoreend

It worked fine until yesterday.
I use RPAExpress 1.1.20

Any help appreciated.

Br,
Dimitrios

@ashapkina

Could you tell if / and /i flags are not valid for WF? What should I use instead?

Hi Dimitrios,

I’m not sure why the flag stopped working.

Try using flags (?i) and (?-i) for ignore case.

Super, it all works perfect now with (?i) and (?-i)
many thanks :slight_smile:

1 Like

I’m glad I could help :grinning: