thanks for reading my question.
I am using a RegExp object in actionscript to simply test the occurrence of one string inside another. Sometimes the Strings may contain RegEx special characters, i.e. “*”.
To handle that I have been concatenating \Q to the beginning of the search string, like so…
(String(reportItem[attributeToSearch])).search(new RegExp(("\Q" + searchText), "i"))
That is currently working for larger strings and for the string “*“.
However, I’ve come across a problem where the String I am searching is “projectiles, with bursting charge”. I am search for “,s” and it gives me back -1 as a result. If I search the same thing without the \Q it works fine, but then the “*” case breaks.
What gives?!
Thanks in advance!
You need to escape the
\in the\QTry this: