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

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

Community Beginner ,
May 03, 2017 May 03, 2017

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
4.9K
Translate
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".

...
Translate
Engaged ,
May 03, 2017 May 03, 2017

Hi,

Please post screenshot.

Thanks

Thanks,
Prabu
Design smarter, faster, and bolder with InDesign scripting.
Translate
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

hi,

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

Thanks,

Translate
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

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]|[ÈÆ©®Ð]

Translate
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

Hi,

\<\u\w+

Thanks

Thanks,
Prabu
Design smarter, faster, and bolder with InDesign scripting.
Translate
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

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,
Prabu
Design smarter, faster, and bolder with InDesign scripting.
Translate
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

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

Translate
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

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.

Translate
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

Hi there,

Thanks a lot:) It's very helpful

Translate
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
LATEST

Hi Jongware,

You forgot Blanche-Neige!  😉

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

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

(^/)

Translate
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