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

GREP Style: find 2 or more words, only first letter cap

Community Beginner ,
May 03, 2017 May 03, 2017

Copy link to clipboard

Copied

Hi, I'm using ID CS4, I need to find all words in the paragraph like this: Any Two Or More Words followed by body texts onwards.

Can anyone pls help, thanks.

Lily

TOPICS
Scripting

Views

4.0K

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 , May 04, 2017 May 04, 2017

To find 2 or more capitalized words, use this GREP:

\b\u\w+(\s+\u\w+)+

Lots of escaped codes! Let's go through them one at a time.

The first \b is a word break. In this position, it means the next character (which must be a letter) must be at the start of a word. It is called "word break" because you can also use it to mark the end of a word ("rune\b" will find "prune" but not "runes"), and the full technical explanation is "there must be a word character on one side and not one on the other side".

...

Votes

Translate

Translate
Engaged ,
May 03, 2017 May 03, 2017

Copy link to clipboard

Copied

Hi,

Please post screenshot.

Thanks

Thanks
AP

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 ,
May 03, 2017 May 03, 2017

Copy link to clipboard

Copied

hi,

i want to convert text Frame to text Fields for making interactive Pdf so can help me pls..

Thanks,

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 ,
May 04, 2017 May 04, 2017

Copy link to clipboard

Copied

I'm trying to make GREP expression to find all words that starts with the

capital letter (like Italy, America, Europe, John, etc) and to mark them

with the character style.

I have found one discussion, but the GREP is non-recognisable, \<[A-Z]|[ÈÆ©®Ð]

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
Engaged ,
May 04, 2017 May 04, 2017

Copy link to clipboard

Copied

Hi,

\<\u\w+

Thanks

Thanks
AP

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
Engaged ,
May 04, 2017 May 04, 2017

Copy link to clipboard

Copied

Hi,

Try this code!!!

var myDoc = app.activeDocument;

app.findGrepPreferences = app.changeGrepPreferences = null;

app.findGrepPreferences.findWhat = "\\<\\u\\w+";

var found = app.activeDocument.findGrep();

for(i=0; i<found.length; i++)

{

found.appliedCharacterStyle = "Bold"; // Change your Character style

}

app.findGrepPreferences = app.changeGrepPreferences = null;

Thanks,

Prabu

Thanks
AP

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 ,
May 04, 2017 May 04, 2017

Copy link to clipboard

Copied

Hi, Prabu

Sorry I'm using mac and I have really no idea whats the code about as I don't know any coding knowledge, thanks anyway

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 ,
May 04, 2017 May 04, 2017

Copy link to clipboard

Copied

To find 2 or more capitalized words, use this GREP:

\b\u\w+(\s+\u\w+)+

Lots of escaped codes! Let's go through them one at a time.

The first \b is a word break. In this position, it means the next character (which must be a letter) must be at the start of a word. It is called "word break" because you can also use it to mark the end of a word ("rune\b" will find "prune" but not "runes"), and the full technical explanation is "there must be a word character on one side and not one on the other side".

\u is a shortcut for "any single uppercase character". It matches A-Z, Α-Ω (Greek), and even А-Т (Cyrillic), with or without accents!

\w is a shortcut for "any single word character". A "word" character is anything that can be part of a word, so both uppercase A-Z and lowercase a-z, 0-9, as well as loads of Greek, Cyrillic, Hebrew, Arabic, Japanese, Chinese, and Thai characters. Some that are not "word" are: spaces, punctuation, parentheses, hyphens, and the '&' character.

The '+' ensures 'one or more' word characters must follow the initial uppercase.

\s is a shortcut for "any space character". It will not only match a single space, but also a tab and InDesign's list of more specialized whitespace characters – nonbreaking, third, en, em, figure, and so on.

Again, the '+' allows more than one.

This is followed by another group of 'at least one capital, then anything'.

There are parentheses around the space-then-next-word and a '+' after this, because this entire group – the space plus a possible second word – must occur at least once, and may occur more. This will grab entire sequences of capitalized words at once.

This is what it looks like:

words.PNG

It ignores the first "Hi, I" because there is a comma in between, and also "I" is not followed by (at least) one additional letter. It then correctly picks up the combination "ID CS4", stopping at the first non-word character (the comma), and then it matches the entire phrase "Any Two Or More Words" as one long sequence.

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 ,
May 04, 2017 May 04, 2017

Copy link to clipboard

Copied

Hi there,

Thanks a lot:) It's very helpful

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
LEGEND ,
May 04, 2017 May 04, 2017

Copy link to clipboard

Copied

LATEST

Hi Jongware,

You forgot Blanche-Neige!  😉

… and here we go: Who are the 'seven dwarfs'?

Personally, surely ´Simplet' (in French)!  😉

(^/)

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