• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Grep with FindChangeByList.jsx

Enthusiast ,
Oct 18, 2007 Oct 18, 2007

Copy link to clipboard

Copied

I want to use this regex:

find:
(\d\d?).(\d\d?) ?- ?

change:
$1.$2~=

Within the normal Find/Change dialog it's not a problem. But if I take the expression to the FindChangeList.txt to use with the FindChangeByList.jsx I receive no results. Who can help me?

This is my line in the FindChangeList.txt:
grep {findWhat:"(\d\d?).(\d\d?) ?- ?"} {changeTo:"$1.$2~="} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}

Thank you! Haeme Ulrich
TOPICS
Scripting

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 19, 2007 Oct 19, 2007

Copy link to clipboard

Copied

You need to escape the backslashes:
>{findWhat:"(\\d\\d?).(\\d\\d?) ?- ?"}

Peter

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 19, 2007 Oct 19, 2007

Copy link to clipboard

Copied

Hi Peter

Thank you for your quick answer. Unfortunately the problem still extists.

Haeme

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 19, 2007 Oct 19, 2007

Copy link to clipboard

Copied

It works now. The problem was - after the escaping - that I had the older version of the script. Thank you!
Haeme

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 03, 2008 Mar 03, 2008

Copy link to clipboard

Copied

thanks a lot !!!! 3 days i'm looking for this bug !!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 05, 2008 Jun 05, 2008

Copy link to clipboard

Copied

Fascinating. Thanks Peter! Solved my problem too.

But Peter, why is it necessary, given that the default 'FindWhats' don't use escaped backslashes, ie:

grep {findWhat:"\t\t+"} {changeTo:"\t"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false} Find all double tab characters and replace with single tab characters.

?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 06, 2008 Jun 06, 2008

Copy link to clipboard

Copied

Aaron,

I don't know, probably a mistake. It's an easy one to make, as I find out almost every day. By the way, there's a comment in the script that tells you to escape backslashes:

//If you enter backslashes in the findWhat property of the findGrepPreferences object,

//they must be "escaped" as shown in the example below:
//
//{findWhat:"\\s+"}


Peter

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 06, 2008 Jun 06, 2008

Copy link to clipboard

Copied

Ah, I missed that comment in the file!

But I can't understand 2 things:
1) How Olav could possibly have made a mistake! :)
2) How come his lines work without being escaped, whereas mine was utterly ignored?

Cheers,
Aaron

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 06, 2008 Jun 06, 2008

Copy link to clipboard

Copied

Well, it probably wasn't a mistake after all (heaven forbid!). When you use \t and \r you don't need to escape the backslash. When you write "\\t" the script uses \t (you can see that in the Find/Change dialog after running the script). But when you write "\t" in the script, it in fact uses the tab control character: after running this, the Find/Chage dialog shows a small square.

So it happens that with \t and \r there's no need to escape because these two have a special meaning in general. For instance, you can use them in alerts to tab or create new lines. All other backslashed should be escaped though, as without them the strings become meaningless.

Peter

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 06, 2008 Jun 06, 2008

Copy link to clipboard

Copied

Aha. I think I get it. Thanks for the explanation!

Aaron

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 06, 2008 Jun 06, 2008

Copy link to clipboard

Copied

Can you use the findchangeby list to apply certain character style. I have tried and only the find and replace portion of the script seems to work. I want to find several instances of all capped words and turn them into superscripts.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 06, 2008 Jun 06, 2008

Copy link to clipboard

Copied

You need this:
grep[TAB]{findWhat: "\\u+"}

[TAB]{position: Position.superscript}
[TAB]{includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true}
[TAB]Caps to super


but replace [TAB] with a proper tab, and it should be on one line, so no returns.

Peter

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 06, 2008 Jun 06, 2008

Copy link to clipboard

Copied

I have several lines that look like this
********* ******* ******* 225/45R17XL *** ** ** ** **
The spaces between the astrixs represent TABs
I want the XL to be superscript

I have several other items that i need superscript all would be capped. Not all have the same amount of characters. (i.e) RRBL, RFT, XL, DSST

since the info i want to change is after the 3rd tab would this be it?

grep[TAB]{findWhat: "\\u+"}
[3]{position: Position.superscript}
[3]{includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true}
[3]Caps to super

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 06, 2008 Jun 06, 2008

Copy link to clipboard

Copied

LATEST
Ryan,

Where I wrote "replace [TAB] with a proper tab" I meant remove [TAB] and press the tab key. Each line in the script has five elements separated by a tab. That's explained in the script itself, so you should first read that introduction. Your proposed solution and your query about variable-length strings suggest that it's probably also a good idea for you to familiarise yourself with Grep.

What you want to achieve is not entirely straightforward. Your original problem (just finding strings up capitals) is easy; what you describe in your last post is a different matter.

Peter

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines