Creating a GrepList Template to Bypass Special Characters?
jjweimer
MyWave(1);MyWave(1)0;MyWave(1)1;MyWave(2);wave0;wave1;
I want to count for the number of items in this list that have the pattern MyWave(1)* (there are three in this case). I am trying with GrepList(...), however I am confused about how to bypass the existing special characters () in a "(?i)MyWave(1).*" type RegExp template. I also want to be able to handle a wide range of cases with special characters in their names, such as ...
MyWave[1];MyWave[1]0;MyWave[1]1;MyWave[2];wave0;wave1;
... and I want to do this without presumptions about what special characters are in the template that should be matched.
Basically, I wonder if a meta escape switch ... say X ... exists to construct "(?iX)MyWave(1).*" so that every character given in the RegExp template is interpreted as a true character rather than a special character.
In this case, you'd want something like:
"(?iX)MyWave\\(1\\).*"
See the comment at:
DisplayHelpTopic "Backslash in Regular Expressions", which indicates that normal grep backslashes need to be doubled up.
August 5, 2008 at 03:23 pm - Permalink
The case I want to handle is more general. I want to be able to search for a template that could be MyWave(1) or MyWave[1] or MyWave{1} or My(1)Wave or ... without knowing beforehand which particular special character is in the template and where it is. I would hope for a "meta-escape" character at the beginning of the string to turn off special character interpretation within the entire template string.
The interest in this is part of a broader context of automatically renaming incoming waves according to their file name. I am searching in the folder for the existence of all waves with the same prefix template as the incoming (file name). File names may have special characters in them. In the meantime, I've decided to forgo automatically renaming incoming waves by liberal file names, so I have no need for a meta-escape character.
Thanks for the response!
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
August 6, 2008 at 04:58 am - Permalink
Well, you could simply put a double backslash in front of every character...
August 6, 2008 at 05:25 pm - Permalink
Oh! Yes of course! It's a rather cumbersome process not-with-standing.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
August 7, 2008 at 08:01 am - Permalink