There is no preference for that: the scope of Find/Replace can be set only with the five preferences you already tried. (Similarly, you can't include/exclude tables.) findGrep() and changeGrep() return an array, by the way, not a collection.
That's good to hear about the return value of findGrep and changeGrep. I just assumed they were collections.
I will write that wrapper function and post it up on this thread.
how do I take in grep $0 or $1 or $2 in script?
I´m looking in grep (\d?\d?\d?)(.?)(\d?\d?\d?)(,?)(\d?\d?) and I want to change ". " to "," and "," to" ." in numbers.
I put "$1"+","+"$3+"."+$5
I have in document these numbers:
I have I want
Thanks for your help
The script is:
var myDoc = app.activeDocument;
var numberfind= "(\d?\d?\d)(.?)(\d?\d?\d?)(,\d\d)";
var numberchange ="$1"+","+"$3"+"."+"$5"; // I think here i have the problem
for(var i =0; numberfind.length > i; i++)
var numWords = theGrepChanger(myDoc,numberfind[i],numberchange[i]) ;
app.findGrepPreferences = NothingEnum.NOTHING;
app.changeGrepPreferences = NothingEnum.NOTHING;
app.findGrepPreferences.findWhat = grepFindIt;
app.changeGrepPreferences.changeTo = grepChangeIt;
var arrGrepFindIt = myDoc.changeGrep();
Please don't start a new topic in an existing thread. Anyway, you'd better use two separate GREPs for what you want: one to swap periods and commas, another one to add decimals to whole numbers. To swap periods and commas, look here: http://tinyurl.com/6m8squ4. To find numbers that don't contain periods of commas, you can use this grep: \b(?<![.,])\d+(?![,.])\b and use $0.00 or $0,00 as the replacement string.
But i want to know how to tell grep structure in script $0, $1...
app.findGrepPreferences.appliedCharacterStyle = app.activeDocument.characterStyles.item(myParagraphStyleName);
foundItems = app.activeDocument.findGrep();
alert ("foundItems "+foundItems.length);
for (var i=foundItems.length-1; i >=0; i--)
var result = foundItems[i].contents; // which is what I started with above
alert("$0 "+'$0');// like this, tell me $0 $0...How I tell $0 of grep
result = result.replace (".", "");
result = result.replace (",", ".");
result2 = String(result2);
foundItems[i].contents = result2;
Thansk for your help
Saying just "i want to know how to tell grep structure in script $0, $1...", then inserting a whole script, isn't particularly helpful.
Then enter your grep expression in the Find What field, then enter just $0 in the Change To field, and press Change all. See what happens. (You could *** underline or a colour to make it better visible.). Undo, then add $1 into the Change To field, and look again what happens. Do the same for $2 etc. This way you can work out what each $n represents.