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

Find/Replace « GREP help

New Here ,
Oct 28, 2021 Oct 28, 2021

Copy link to clipboard

Copied

Hello !

 

I'm a total newbie at using GREP and I tweaked the FindChangeByList script to find and replace a bunch of little things like double spaces, thin spaces before some punctuations mark, etc.

 

Everything works like a charm EXCEPT for the the double quotes « and ».

 

Here is one of the scripts that I use and that works perfectly well :

grep {find what:" [?]"} {change to:"~<[?]"} {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false} Find all space-question mark and replace with a thin space-question mark.
text {find what:"[?]"} {change to:"?"} {include footnotes:true, include master pages:true, include hidden
layers:true, whole word:false} Find all brackets-question marks-brackets and replace with a question mark.
 
(I needed to put the question mark between brackets because it didn't work without. No clue why as I don't know the first thing about GREP).
 
I used the exact same lines and replaced [?] by [«] to apply it to «, but it doesn't work. I've roamed the internet for an answer, and none of what I tried worked.
 
Does anyone out here have a clue why and might be able to help ?
 
Thanks : )
TOPICS
How to , Type

Views

504

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

correct answers 1 Correct answer

Community Expert , Oct 29, 2021 Oct 29, 2021
quote

Just noticed there was an error in the script syntax, which I corrected to : 

text {find what:"« "} {change to:"«~<"} {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false} Remplace guillemet-ouvrant-espace par guillemet-ouvrant-espace-fine.


I am not a scripter at all, but a long time user of this script and I have adapted many times the FindChange text which is associated to this script. So, no, it is not an error: you use the ~ metacharacter when t

...

Votes

Translate

Translate
Community Expert ,
Oct 28, 2021 Oct 28, 2021

Copy link to clipboard

Copied

In place of [?] use \? you need to escape characters that have special meaning in GREP and ? is one such character so that needs escaping, the escaping is not needed inside a character class that is why enclosing it seems to work for you. For the other replacement just use the character it is not a special character so it would need any escaping nor does it need to be inside a character class

 

In your first example you are replacing "all space-question mark with a thin space bracket open question mark backet close". Due to this reason you need the second text replace. Instead you could use just a single ind/replace like the following

grep {find what:" \?"} {change to:"~<?"} {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false}

-Manan

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 ,
Oct 28, 2021 Oct 28, 2021

Copy link to clipboard

Copied

What dou you want to finally get? A thin space after the opening quote («) and before the closing one (») ?

This works fine, using the FindChangeByList script

text {findWhat:"« "} {changeTo:"«^<"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:false, wholeWord:false} Remplace guillemet-ouvrant-espace par guillemet-ouvrant-espace-fine.
text {findWhat:" »"} {changeTo:"^<»"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:false, wholeWord:false} Remplace espace guillemet-fermant par espace-fine-guillemet-fermant.

 

Note that this text file comes from JRBoulay web site, who adapted the original one to match the French typographic rules

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 ,
Oct 29, 2021 Oct 29, 2021

Copy link to clipboard

Copied

Hey @Manan Joshi and @jmlevy  ! Thank you both for you replies.

 

So I tried both, but I get errors… 

 

Screenshot 2021-10-29 at 09.56.09.pngScreenshot 2021-10-29 at 09.52.10.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

@jmlevy yes, I absolutely want a thin space after the («) and before the (»). I have no clue why it works fine with the rest of my script, but not the quote. 

 

I attached the full script. Maybe there's something somewhere that I'm not seeing !

 

Thanks for your help : )

 

 

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 ,
Oct 29, 2021 Oct 29, 2021

Copy link to clipboard

Copied

Just noticed there was an error in the script syntax, which I corrected to : 

text {find what:"« "} {change to:"«~<"} {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false} Remplace guillemet-ouvrant-espace par guillemet-ouvrant-espace-fine.

 

Now I don't get an error,  but it STILL doesn't work 😰

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 ,
Oct 29, 2021 Oct 29, 2021

Copy link to clipboard

Copied

quote

Just noticed there was an error in the script syntax, which I corrected to : 

text {find what:"« "} {change to:"«~<"} {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false} Remplace guillemet-ouvrant-espace par guillemet-ouvrant-espace-fine.


I am not a scripter at all, but a long time user of this script and I have adapted many times the FindChange text which is associated to this script. So, no, it is not an error: you use the ~ metacharacter when the string is a grep one, but as you have seen in my answer, it is a text string and the metacharacter you need to use is ^, not ~.

 

I can guarantee you that the FindChange text file I use (and the 2 lines I gave you are extracted of this text file) works perfectly.

May I ask if you are a French speaking person and if you want to use French typographic rules? If this is the case, I invite you to download this version of the script here:

https://www.abracadabrapdf.net/utilitaires/utilitaires-indesign/indesign-jsfindchangelist-en-version...

 

I have modified many times this file to match with different needs and it has always worked perfectly, so maybe your error comes from the javascript itself, but unfortunately I cannot help you on this matter.

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 ,
Oct 29, 2021 Oct 29, 2021

Copy link to clipboard

Copied

Thanks @jmlevy I'll try that file. Hopefully I don't get an error !

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 ,
Oct 29, 2021 Oct 29, 2021

Copy link to clipboard

Copied

There is definitively something wrong in your FindChangeList file but I am unable to understand where the error(s) is (are). If you follow my advice, it should work.

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 ,
Oct 29, 2021 Oct 29, 2021

Copy link to clipboard

Copied

Hi @Chillidrop.

The attached file works for me, try it. If it still does not work then share a sample InDesign file that we can test with.

-Manan

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 ,
Oct 29, 2021 Oct 29, 2021

Copy link to clipboard

Copied

Hey @Manan Joshi I just tried it and still nothing : (

 

I created a blank document to try it in, and nothing happened. When I used my old file, the ? worked.

I attached it if you want to try.

 

I'm so confused haha.

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 ,
Oct 29, 2021 Oct 29, 2021

Copy link to clipboard

Copied

Works just fine for me, I used the indd you sent and the txt file that I sent before. See the screengrab at the following link

https://www.dropbox.com/s/yn2iabukuq5fb88/Screen%20Recording%202021-10-29%20at%206.53.44%20PM.mov?dl...

-Manan

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 ,
Nov 02, 2021 Nov 02, 2021

Copy link to clipboard

Copied

LATEST

Hey @Manan Joshi and @jmlevy 

 

So I finally figured out what was wrong! I was using the applescript file and not the javascript ! 

 

@jmlevy I used the file you suggested in javascript and it works like a charm !

 

Thank you both for you precious advice and time : )

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