Case sensitive regular expression

Best practices, code snippets for common functionality, examples, and guidelines.
BeardMJ
Posts: 33
Joined: Wed May 31, 2017 8:39 am

Case sensitive regular expression

Post by BeardMJ » Tue Aug 15, 2017 12:14 pm

Hi Guys

I have the following components with the text = Designators

But some are upper and some are lower, my current expression is:

form[@text~'^(?i:Designator)$']

But Ranorex still won't see it, any help appreciated.

Regards

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

Re: Case sensitive regular expression

Post by odklizec » Tue Aug 15, 2017 12:35 pm

Hi,

If the text you are looking for is Designators, then you must either remove '$' sign from the regex (which means the end of the string) or you must include 's' to the searched pattern.
^(?i:Designator)
or like this:
^(?i:Designators)$
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

BeardMJ
Posts: 33
Joined: Wed May 31, 2017 8:39 am

Re: Case sensitive regular expression

Post by BeardMJ » Tue Aug 15, 2017 4:30 pm

Hi mate

I've done both these things and it still won't get picked up with either of the following:

form[@title~'^(?i:Designator)$']

form[@title~'^(?i:Designators)']

I used both title and text as title is what is picked up by SPY.

Cheers

BeardMJ
Posts: 33
Joined: Wed May 31, 2017 8:39 am

Re: Case sensitive regular expression

Post by BeardMJ » Tue Aug 15, 2017 4:42 pm

Hi

I forgot to mention the whole title is:

THAMES Designators - BLANK

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

Re: Case sensitive regular expression

Post by odklizec » Tue Aug 15, 2017 5:03 pm

Hi,

In this case, the regex should look like this...
(?i:Designators)
'^' character means 'start of string' but your sought word is apparently in the middle of string ;)
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

BeardMJ
Posts: 33
Joined: Wed May 31, 2017 8:39 am

Re: Case sensitive regular expression

Post by BeardMJ » Tue Aug 15, 2017 5:21 pm

Hi mate

So literally:

Title~'(?I:Designators)']

Yes apologies the middle word as the other two are variables

BeardMJ
Posts: 33
Joined: Wed May 31, 2017 8:39 am

Re: Case sensitive regular expression

Post by BeardMJ » Wed Aug 16, 2017 8:12 am

Thanks mate that worked

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

Re: Case sensitive regular expression

Post by odklizec » Wed Aug 16, 2017 8:15 am

You are welcome. I'm glad I could help ;)
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