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

Find/Change from a specific phrase until two paragraph breaks

New Here ,
Jun 30, 2021 Jun 30, 2021

Copy link to clipboard

Copied

I hope to automate certain styles in a Songbook I'm putting together. The choruses are meant to stand out with their own style.

 

I've been messing around with GREP, trying to use Find/Change to select something like this:

 

[Chorus]
F#m
Oh oh stand by me
D E A
Oh oh stand stand by me stand by me

 

I want to search first by [Chorus], select all the lines in between, then end at two paragraph breaks as the verse starts.

 

I've had success with a couple commands so far. They will select about 8 or so, but not all, of which there are hundreds.

 

1. \[Chorus\]\r[\s\S]*?\r\r

 

2. \[Chorus\]\r(?!CS.*?)[\s\S]*?\r\r

 

I really just cobbled these together from reading online, so they really might look unusual and very questionable.

 

Any ideas why these might not select every one? I've checked and the other potential matches do have extra lines before the chorus.

TOPICS
Scripting

Views

164

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 , Jun 30, 2021 Jun 30, 2021

You have spaces before the single return.
Either fix this before using the code I gave you or you can try with this new one:

(?s)\[Chorus\].+?(?=\r(\h?\r)+)

 

Votes

Translate

Translate
Community Expert ,
Jun 30, 2021 Jun 30, 2021

Copy link to clipboard

Copied

Work with ifferent paragraph styles and select only those you want to edit.

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
New Here ,
Jun 30, 2021 Jun 30, 2021

Copy link to clipboard

Copied

That is my goal. I will use Find/Replace to replace the found text with the correct character style.

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 ,
Jun 30, 2021 Jun 30, 2021

Copy link to clipboard

Copied

Hello, use to to apply your special style for the Chorus...

(?s)\[Chorus\].+?(?=\r\r)

 

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
New Here ,
Jun 30, 2021 Jun 30, 2021

Copy link to clipboard

Copied

Merci bien de m'aider!

Unfortunately that didn't work. It does select the 7-8 choruses I mentioned that got selected with the code I mentioned in the original post:

 

grep1.jpg

 

But this chorus was not selected:

 

grep2.jpg

 

I wonder if I'm missing something very obvious.

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 ,
Jun 30, 2021 Jun 30, 2021

Copy link to clipboard

Copied

You have spaces before the single return.
Either fix this before using the code I gave you or you can try with this new one:

(?s)\[Chorus\].+?(?=\r(\h?\r)+)

 

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
New Here ,
Jun 30, 2021 Jun 30, 2021

Copy link to clipboard

Copied

LATEST

Parfait, merci!

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 ,
Jun 30, 2021 Jun 30, 2021

Copy link to clipboard

Copied

Looks to me like the chorus that didn't get captured has a space before the paragraph marker. See the dot representing the space right before the paragraph marker? If you're looking for \r\r, your regex won't find that chorus that is actually \r\s\r.

 

What I'd do in your shoes is a two-pass search, where first I'd look for " \r" (note the space before the slash) or alternately "\s\r" which is "any white space followed by a paragraph marker". Replace that with a single \r, and run the search a few times to make sure that you get zero replacements, in case there are choruses that have two or more spaces before the paragraph marker. 

 

Alternately, you could stick with a single regex and make your lookahead cover more possibilities... I think it would look like this:

 

(?=\r\r|\r\s\r)

 

that looks for either "\r\r" or "\r\s\r". However, I have no idea how to test that regex on my phone, so it's just a guess, I can't recall if one can use an OR in a lookahead. 

 

 

Edit: Oooh, Jean-Claude's regex is much better than mine, use his instead!

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