11-21-2014 07:35 PM
hello,
i am trying to use the match pattern with ~ for exclusion as follows
string1 = ERROR_SHOTDATA_10.rsd
string2 = BQERROR_SHOTDATA_10.rsd
pattern = [~BQ]ERROR_SHOTDATA ( i want to find string1 with this pattern)
match pattern cannot find string 1, any reason wy the exclusion not working , is my regex wrong?
11-21-2014 09:24 PM
I don't use regex as much as I should and I couldn't figure out how to do what you were trying to do in the way you were trying to do it but here's a regex that finds string 1 but not string 2.
^(ERROR_SHOTDATA_)[0-9]{1,2}(\.rsd)
I assumed your filename might have a number between 0 and 99 and not always "10".
Remove the leading caret to fing the properly formed portion of the (presumably) corrupted string 2.
11-21-2014 09:53 PM
thanks
your regex is not finding any, and even if i remove caret, it will find both BQERROR and ERROR ,
the strings are in array and i have regexes for each also in array and i am using for loops to go through strings and regexes, all other strings have some uniquie name in them so its able to match pattern with exact words except these two.
thats why i want to exclude [~BQ], but for reasons i cannot understand its not matching it.
i have a different folder whose contents can have
string1 = serial-mmddyy-hhmmsssss-ERROR_SHOTDATA_10.rsd
string2 = serial-mmddyy-hhmmsssss-BQERROR_SHOTDATA_10.rsd
so i still want to use only 1 regex for both folders and still find either ERROR or BQEROR
11-22-2014 02:15 AM
I am not that good in regex, but here is something you may try:
(?<=BQ)ERROR_SHOTDATA.*
11-22-2014 09:56 AM
11-22-2014 11:49 AM
it gives match = QERROR_SHOTDATA
11-22-2014 02:03 PM
11-22-2014 02:11 PM
ok it works on match regex, but not on match pattern,
it still bugs me that my original try with ~ doesnot work, it looks as simple as the help file indicates, what could be wrong?
Help-->Match Pattern Function
The longest string within parentheses but not containing any parentheses within it ([~()]*)
11-22-2014 02:19 PM
Read the detailed help file for Match Pattern. It does NOT handle all possible regular expressions. There is a subset of special characters that it accepts. It may be that your expression is not in the subset.
Lynn
11-22-2014 03:15 PM
As Lynn mentioned, Match Pattern doesn't implement the full Regex syntax, but only implements a subset of it and that even sometimes in a special way.
Your search has however one big problem. The [~BQ] part already matches the entire ERROR_SHOTDATA10.rsd string leaving nothing for the Match Pattern to match the ERROR_SHOTDATA pattern that follows so ending up with nothing.
Match Pattern only can indirectly be used to detect your specific request. Basically you would have to search for ERROR_SHOTDATA and also check the string in the "before substring" output to not end in your BQ string (basically using Match Pattern again with the BQ$ search pattern and checking offset past match to be < 0.