Page 1 of 1

Regular Expression

Posted: Wed Aug 13, 2014 2:29 pm
by NewLearner
accessibledescription='dgo_ObjectID=#Ctrl1D.Pad.Row14

accessibledescription='dgo_ObjectID=#Ctrl1C.Pad.Row14

please let me know how to user regular expression for above statement, only different is statement 1 has D and statement 2 has C...pls let me know how to handle this using regular expression

Thank you

Re: Regular Expression

Posted: Wed Aug 13, 2014 2:38 pm
by krstcs
@accessibledescription~'dgo_ObjectID\=\#Ctrl1[C-D]D\.Pad\.Row14'

You need to escape all control characters ("=", "#", ".") using a backslash.

Also, notice the bracketed group "[C-D]". This tells regex to look for either capital C or capital D in the location of the "[...]". You can put whatever letters/numbers in there you want, for example if you need A-Z and a-z, then you would do it like this: "[a-zA-Z]".

Checkout this site for more info on Regex: http://www.regular-expressions.info/

It has lots of information and examples. Note that Ranorex is built on .NET, so it uses .NET Regex syntax, which is slightly different then JavaScript's (and others') Regex syntax.