Skip to main content
dublove
Legend
July 16, 2024
Answered

The same regular expression can be found, but why the GREP in the paragraph style cannot be recogniz

  • July 16, 2024
  • 2 replies
  • 871 views

The same regular expression can be found, but why the GREP in the paragraph style cannot be recognized

\w\w\W*$

What's incredible for this expression?

This topic has been closed for replies.
Correct answer dublove

Thanks.
\h is a good thing, I haven't noticed before.

Also \H is good thing.

2 replies

Peter Spier
Community Expert
Community Expert
July 16, 2024

Instead of \W you might want to try using the wild cards for what you are really trying to find, perhaps [[:punct:]] and \h to find horizontal whitespaces but not end of paragraph, new line or column/page breaks.

dublove
dubloveAuthorCorrect answer
Legend
July 17, 2024

Thanks.
\h is a good thing, I haven't noticed before.

Also \H is good thing.

Robert at ID-Tasker
Legend
July 16, 2024

Try

 

\w\w\w*$

 

All three "w" should be small caps.

 

"\W" isn't a correct meta - so you get only two letter results - "*" means "zero or more".

 

https://www.indiscripts.com/blog/public/data/idcs4-special-characters/en_InDesignCS4-CS5-SpecialChars.pdf

 

dublove
dubloveAuthor
Legend
July 16, 2024

You don't understand what I mean
\w refers to any character (excluding space and punctuation)
\W contains space and punctuation.
They are different

 

I mean:
\w\w\W*$ can find the content, but it seems that it does not work in the paragraph style GREP.

Of course, no wrap is  difference  in Chinese and English.

James Gifford—NitroPress
Legend
July 16, 2024

I'm not sure where you're getting the information, but InDesign's implementation of GREP uses \W as the opposite of \w — any "non word" character instead of "any word character." It excludes letters and "word" punctuation like underscores.

 

  • \w — a-z, A-Z, 0-9 and underscore.
  • \W — any character NOT in the above list.

 

The wildcard for "any character" is a period, full stop - "."