String matching with Grep
Peeyush Khare
Hello,
This maybe a very simple thing but somehow it is eluding me even after trying to run through the IGOR manuals and looking through the help topics.
I am using Grep to match "Na2[15N]O3+" in a list. Igor is however matching Na2NO3+. I think IGOR is reading it like a regex expression in some shape or form but I don't understand why it is matching Na2NO3+ instead of Na2[15N]O3+. I want to force the program to match this formula with [15N] included in the string.
Would be thankful for your advice on how to pull this off.
Sincerely,
Peeyush
Here is a working example that may help:
print GrepList(sList, "Na2[15N]O3+" ) // prints: Na2NO3+;
print GrepList(sList, "Na2\[15N\]O3\+" ) // prints: Na2[15N]O3+;
print ListMatch(sList, "Na2[15N]O3+") // prints: Na2[15N]O3+;
The first is my guess at the sort of thing you have a problem with.
The second escapes the GREP characters that have special meanings [, ], +
The third does not use GREP (but beware * if used can be wildcard characters).
November 21, 2023 at 01:39 am - Permalink
Great! The "\" worked! Thanks a lot @KurtB.
November 21, 2023 at 01:49 am - Permalink