How to use Regex in Recording variables

Ask general questions here.
s.abdourafiq
Posts: 12
Joined: Mon May 03, 2021 12:44 pm

How to use Regex in Recording variables

Post by s.abdourafiq » Tue May 04, 2021 3:26 pm

Hi,

I used the CheckFilesExists function of Ranorex library and I want to variate the pattern so i put it as a variable, but I want to customize it so that the pattern will start with the value of the variable and end with any text because the end of the name of the file changes.

To do so, I tried to use Regex in my variable but it does not work.
Is there a way to use Regex ?
Capture d’écran 2021-05-04 142452.png
Thank you
You do not have the required permissions to view the files attached to this post.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to use Regex in Recording variables

Post by odklizec » Wed May 05, 2021 8:40 am

Hi,

I'm afraid, regex cannot be used like this in user code parameters. What you actually need to do is to manipulate the content of variable, either before using variable in user code method, or directly in method.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

s.abdourafiq
Posts: 12
Joined: Mon May 03, 2021 12:44 pm

Re: How to use Regex in Recording variables

Post by s.abdourafiq » Wed May 05, 2021 11:08 am

Thank you for your answer.

And for anyone who needs to know, i managed to do that by adding a user code before the checkFilesExists, that concatenates two values, the first value takes the variable and the second one takes the regex metacharacter and i gave the returning concatenated value to the pattern.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to use Regex in Recording variables

Post by odklizec » Wed May 05, 2021 11:29 am

Hi,

Thanks for sharing your solution! ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration