0

What is the GREP code for finding all words between a full stop (.) and a colon (:) and then selecting those words and the colon (but not the fullstop)? For example: '. Tone:' or '. Final result:') in a body of copy. Thanks.

2 Answers 2

1

You need a positive look-behind

(?<= ... )

And a positive look-ahead

(?= ... )

\. Dots need to be backslashed.
/s for the space.
\w for letters and numbers.
? for optional characters.
And * to catch multiples.

(?<=\.\s?)\w*(?=:)

I recommend regex101.com to help create and lookup regex syntax.

0

If the period . might also be preceded by a word, as per your example, "somthing. Tone:" you might try this:

(?<=[a-z.]\s)[\w\s]+:

"Tone:" will be selected if your string looks like ". Tone:"; and "some other thing Tone:"will be selected if your string is "something. some other thing Tone:"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.