match(/\w/g) does NOT match findGrep() with .findWhat = "\\w"
- October 23, 2009
- 1 reply
- 2780 views
Hello, everybody!
As you might know \w is not \w when it comes to GREP search by different means. I learned the hard way that I cannot be sure when using match() or findGrep() that I'm getting identical results. The difference in technique seems clear to me: match() uses a search in memory independing of the InDesign-specific GREP search.
Please correct me if I'm wrong, but shouldn't both methods yield the same results using the same GREP pattern? Using the dot as pattern does.
Is it because of a "bug" in ExtendScript?
To illustrate the problem I wrote a script that opens a new document with a text frame labeled "ToSearch" with a lot of characters from the German keybord. Then that will be searched by findGrep() and match() alike. Results are written to new text frames on the page labeled accordingly.
The script searches for the following patterns:
\w
[0-9A-Za-zÀ-ü]
In the case of [0-9A-Za-zÀ-ü] there is no difference in "scope" of the GREP pattern.
\w is a different beast. German Umlauts are not to be found, etc.etc.
But see for yourself. I tested this script with InDesignCS3 ESTK 2 and InDesign CS4 ESTK. There are inconsistent results from CS3 to CS4. CS4 shows more find results than CS3. E.g. "ß" was not found by CS3 when using findGrep().
Is there any documentation how Adobe implemented core JavaScript GREP to ExtendScript so I can be sure of the specific "scope" of a GREP wildcard?
Hope you can help,
Uwe Laubender
Attached Script: FindGrep_vs_match.jsx

