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

lining up several conditions for a single GREP style

Community Beginner ,
Sep 23, 2022 Sep 23, 2022

Copy link to clipboard

Copied

I am relatively new to GREP, using it for simple functions so far.

First, after some searching, I still I haven't found yet one comprehensive directory that lists all the different modifiers and what each does... i found helpful examples here and there but nothing systematic and thorough. for example what using the [ vs the ( vs the { does, and so on.

Second, the specific case i have, is rather simple. also searching led me to nothing on that. i want to include several variables in a single expression that use, in the end, the same style (without having to create a single GREP for each). For example, i want all the instances of and (literally the word 'and') and the periods to use one specific style... i tried space, no space, grouping within different sorts of brackets etc... nothing worked. many thanks for any help!

TOPICS
Actions and scripting

Views

346

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 3 Correct answers

Community Expert , Sep 23, 2022 Sep 23, 2022
quote

I am relatively new to GREP, using it for simple functions so far.

First, after some searching, I still I haven't found yet one comprehensive directory that lists all the different modifiers and what each does...


By @naj.a

 

I'll split my reply into two parts, the first containing some links that I found helpful when "learning" regular expressions (the learning is far from over).

 

I dedicated about one year of "free time" to achieving a good grounding in regular expressions before learning to

...

Votes

Translate

Translate
Community Expert , Sep 23, 2022 Sep 23, 2022
quote

Second, the specific case i have, is rather simple. also searching led me to nothing on that. i want to include several variables in a single expression that use, in the end, the same style (without having to create a single GREP for each). For example, i want all the instances of and (literally the word 'and') and the periods to use one specific style... i tried space, no space, grouping within different sorts of brackets etc... nothing worked. many thanks for any help!


By @naj.a

 

The rege

...

Votes

Translate

Translate
Community Expert , Sep 24, 2022 Sep 24, 2022

@naj.a 

Try the InDesign forum: https://community.adobe.com/t5/indesign/ct-p/ct-indesign

 

Erica Gamet (who speaks at all the conferences) has a cheat sheet here:

http://www.ericagamet.com/wp-content/uploads/2016/04/Erica-Gamets-GREP-Cheat-Sheet.pdf 

 

And some videos on her website:

http://www.ericagamet.com/

 

Jane

 

Votes

Translate

Translate
Adobe
Community Expert ,
Sep 23, 2022 Sep 23, 2022

Copy link to clipboard

Copied

quote

I am relatively new to GREP, using it for simple functions so far.

First, after some searching, I still I haven't found yet one comprehensive directory that lists all the different modifiers and what each does...


By @naj.a

 

I'll split my reply into two parts, the first containing some links that I found helpful when "learning" regular expressions (the learning is far from over).

 

I dedicated about one year of "free time" to achieving a good grounding in regular expressions before learning to script. This helped in InDesign (grep searches and grep styles) and also in my other work manipulating input for databases. It also helped me to modify some scripts without knowing how to script. For me, there was no single definitive source of information. I must have looked at hundreds of websites (text pages, cheat sheets, examples, videos etc). I can only read so much on regex before my brain locks up, I have to experiment and put the info to use. All of the various resources came together, repetition, practice etc.

 

First, a couple of regex testers, which are invaluable and can help you to learn and test:

https://regex101.com/

https://regexr.com/

 

General info:

https://www.regular-expressions.info/quickstart.html

https://www.regular-expressions.info/tutorial.html

https://www.boost.org/doc/libs/1_53_0/libs/regex/doc/html/boost_regex/syntax/basic_extended.html

https://qntm.org/re_en

http://web.archive.org/web/20090209182018/

http://immike.net/blog/2007/04/06/the-absolute-bare-minimum-every-programmer-should-know-about-regul...

 

The most common info is on PCRE or Perl Compatible Regular Expressions... There are some differences with JS regex, don't let it bother you too much in the beginning, just keep in mind that it can sometimes trip you up as a valid PCRE may not be supported in JS.

 

JS-related info useful for ExtendScript programming:

https://javascript.info/regular-expressions

https://www.regular-expressions.info/javascript.html

https://www.w3schools.blog/regexp-javascript-tutorial

https://www.w3schools.com/jsref/jsref_obj_regexp.asp

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Cheatsheet

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions

https://launchschool.com/books/regex/read/preparations

 

Hope this helps!

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 Beginner ,
Sep 23, 2022 Sep 23, 2022

Copy link to clipboard

Copied

6uhyc3.jpg

(I hope you're a Seinfeld fan!) but seriously, a sincere THANK YOU for taking the time to list all these super valuable resources. Now it is going to be the rabbit hole for me, especially knowing the potentional there. It won't be massive databases for me, but anything that can simplify and automate tedious processes (manuals and booklets and listings and whatnote) is fabulous , such a power trip lol!

Thank you again, the script you suggested worked like a charm, and already from that alone understood a lot about the structure of the expression. Cheers to you buddy!

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 ,
Sep 23, 2022 Sep 23, 2022

Copy link to clipboard

Copied

Yes, I am, and to mangle another quote "We're all winners"! Happy to help, regex is great, except for when it isn't!

 

https://blog.codinghorror.com/regular-expressions-now-you-have-two-problems/

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 ,
Sep 23, 2022 Sep 23, 2022

Copy link to clipboard

Copied

quote

Second, the specific case i have, is rather simple. also searching led me to nothing on that. i want to include several variables in a single expression that use, in the end, the same style (without having to create a single GREP for each). For example, i want all the instances of and (literally the word 'and') and the periods to use one specific style... i tried space, no space, grouping within different sorts of brackets etc... nothing worked. many thanks for any help!


By @naj.a

 

The regex could be similar to:

 

\.|\band\b

 

You can plug that into a regex tester and it should "explain" what is happening (I'm happy to discuss this further if there are any questions).

 

You will need to use the g or global flag in your regex.

 

There can be multiple regexes that achieve the same or similar end, which can be confusing to begin with as there can be many different but "correct" answers.

 

Now, something that needs to be said... Photoshop is not InDesign! I know that this is "obvious", however, one has to have a realistic expectation of what the basic software can do and what scripting can do within the limitations of the host software.

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 ,
Sep 23, 2022 Sep 23, 2022

Copy link to clipboard

Copied


@Stephen_A_Marsh wrote:

Now, something that needs to be said... Photoshop is not InDesign!


 

 

As I read through this thread, I was wondering if I was in the right forum. GREP is built into InDesign for both Find/Change and for applying a Character style within a Paragraph style automatically. There are dropdowns to select the appropriate code.

 

Jane

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 ,
Sep 23, 2022 Sep 23, 2022

Copy link to clipboard

Copied

@jane-e – I wondered as well, but as it was marked as "actions and scripting" I presumed that the regular expression was related to JavaScript in Photoshop.

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 Beginner ,
Sep 23, 2022 Sep 23, 2022

Copy link to clipboard

Copied

@jane-e @Stephen_A_Marsh My bad, I am not sure where i got here exactly, but I swear I was pretty sure I was in InDesign as a starting point in the forums - but now im surprised seeing in the breadcrumbs that i'm in the Photoshop ecosystem. my mind is playing tricks on me now. Now that explains why you said at one point "Now, something that needs to be said... Photoshop is not InDesign!" I was scratching my head since then lol!

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 ,
Sep 24, 2022 Sep 24, 2022

Copy link to clipboard

Copied

@naj.a 

Try the InDesign forum: https://community.adobe.com/t5/indesign/ct-p/ct-indesign

 

Erica Gamet (who speaks at all the conferences) has a cheat sheet here:

http://www.ericagamet.com/wp-content/uploads/2016/04/Erica-Gamets-GREP-Cheat-Sheet.pdf 

 

And some videos on her website:

http://www.ericagamet.com/

 

Jane

 

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 Beginner ,
Sep 24, 2022 Sep 24, 2022

Copy link to clipboard

Copied

Thank you Jane, yeah the cheat sheet was showing up repeatedly in my search results but it seemed like smth that works with who are already more familiar with the system. but it will be definitely more useful now that i grasp the concept of the expressions better. cheers!

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 ,
Sep 24, 2022 Sep 24, 2022

Copy link to clipboard

Copied

 

You're welcome, @naj.a . 😊

 

There are other links on Erica's page, such as to her YouTube channel:

https://www.youtube.com/ericagamet

If you have a specific issue, though, the InDesign forum can assist.

 

Jane

 

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 Beginner ,
Sep 25, 2022 Sep 25, 2022

Copy link to clipboard

Copied

LATEST

Thank you Jane, very much appreciated. all the best! :balloon:

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