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

[Grep] how catch a single quote/ apostrophe in Grep

Participant ,
Feb 08, 2022 Feb 08, 2022

Copy link to clipboard

Copied

Hi guys,

I used a grep style in order to capitalize the first letter of every word on a paragraph (for titles) and I wonder how to correctly catch the single quote/ apostrophe in the sentence, in order not to capitalize some words.

 

\b(?!(d.|de|des|du|et|au|aux)\b)[\u\l]

I used the following grep, which actually works fine but I had to cheat in order to make it work.

\b(?!(d.|de|des|du|et|au|aux)\b)[\u\l]

exemple of sentence to capitalize : " Messieurs, mesdames d'Arizona, bonjour "

 

As you could see, I used " d. " for not Capitalizing the " d' " and not making " D' ".

Since the folowwing grep doesn't work, what should I write to excatly catch the single quote/ apostrophe, rather than cheating using the dot.

\b(?!(d'|de|des|du|et|au|aux)\b)[\u\l] -- not working. the ' isn't recognized, neither \'

 

Thanks for your insights

  

TOPICS
Scripting

Views

383

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 , Feb 08, 2022 Feb 08, 2022

Looks like ID is recognizing the apostrophe as a word boundary. Seems like putting it in a class does work, however.

Try

\b(?!(d[']|de|des|du|et|au|aux)\b)[\u\l]

Also, you may not need the de, des, or du if you use d[eu'] and au may cover aux as well, but I haven't tested that.

Votes

Translate

Translate
Participant ,
Feb 08, 2022 Feb 08, 2022

Copy link to clipboard

Copied

Sorry for the double writting of the grep. A shame we can't edit our posts…

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 ,
Feb 08, 2022 Feb 08, 2022

Copy link to clipboard

Copied

~' is the GREP sequence to find the apostrophe

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
Participant ,
Feb 08, 2022 Feb 08, 2022

Copy link to clipboard

Copied

Well, I tried that one too, but it doesn't work either 😕

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 ,
Feb 08, 2022 Feb 08, 2022

Copy link to clipboard

Copied

Looks like ID is recognizing the apostrophe as a word boundary. Seems like putting it in a class does work, however.

Try

\b(?!(d[']|de|des|du|et|au|aux)\b)[\u\l]

Also, you may not need the de, des, or du if you use d[eu'] and au may cover aux as well, but I haven't tested that.

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
Participant ,
Feb 08, 2022 Feb 08, 2022

Copy link to clipboard

Copied

Thanks for having found the easiest way to do it and thank you for tips as well. I'm still not quite acustomed with the short ways to write Grep and scripts. I'll be there, eventually ^^

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 ,
Feb 08, 2022 Feb 08, 2022

Copy link to clipboard

Copied

This works:

 

 

\<\l(?!')

 

 

Capture d’écran 2022-02-08 à 19.20.51.jpgCapture d’écran 2022-02-08 à 19.21.04.jpg

 but I have a question: why do you want to capitalize the first letter of each word of a title? It's against the French typographic rules and it seems that you work 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
Participant ,
Feb 08, 2022 Feb 08, 2022

Copy link to clipboard

Copied

Thanks for the answer. Seems again there are many ways to get to a viable solution ^^
As per for my need Vs the French typographic rules, I know and understand the point, but let's just say the demand is for the game industry and typographic rules there are commonmy violated for the sake of a supposedly "visual improvement".

Besides, I have no real control on the decison 😕

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 ,
Feb 08, 2022 Feb 08, 2022

Copy link to clipboard

Copied

Been thinking about this a bit more, and while it might be working for you at the moment, I thinjk in the general case it may be a failure as it misght not capitalize some words you might intend to be capitalized if they happen to start with de, au or et.

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
Participant ,
Feb 08, 2022 Feb 08, 2022

Copy link to clipboard

Copied

LATEST

I guess just adding a text space after au/de/... will do the thing 

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