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.
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)+)
Copy link to clipboard
Copied
Work with ifferent paragraph styles and select only those you want to edit.
Copy link to clipboard
Copied
That is my goal. I will use Find/Replace to replace the found text with the correct character style.
Copy link to clipboard
Copied
Hello, use to to apply your special style for the Chorus...
(?s)\[Chorus\].+?(?=\r\r)
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:
But this chorus was not selected:
I wonder if I'm missing something very obvious.
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)+)
Copy link to clipboard
Copied
Parfait, merci!
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!