Using RegExp with aqString.Contains
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Using RegExp with aqString.Contains
I am trying to check to see if a string contains any letters using the following code.
if(aqString.Contains(info[i], /[A-Za-z]/) != -1) { an = "a"; }
This if returns false even when it should return true. Any idea what is wrong?
Thank you,
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
According to this
https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqstring/methods.html
"contains" is obsolete
"find" is the replacement
See if that works for you.
ETA: This looks like a better option
https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqstring/strmatches.html
and here is TC information on regular expressions
https://support.smartbear.com/testcomplete/docs/reference/misc/regular-expressions.html
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Also, both "contains" and "find" don't support regular expressions. The second parameter is the literal "sub-string" that you're searching for, not a regular expression. This is why you're getting a false every time. If you want to determine if a string contains another string based upon regular expression, you should use aqString.StrMatches (https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqstring/strmatches.html)
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much!
