Reply To: GREP – find first space

#75973
Justin Sligh
Member

Eugene’s GREP find/replace will do the trick.

Go with the most simple solution based on the text. If you create a complex GREP, you are more likely to find undesired results.

For the sample text you provided, \w+.?$ is perfect.

If your text is is more complex with punctuation within a single word (e.g., hyphen, apostrophe), you might need something more complex. Here is an example of a more detailed GREP that takes care of words that have one punctuation mark.

(?<=\x20)\w+[[:punct:]]?\w+?(?=[[:punct:]]+$)

“Find one or more word characters followed by a possible punctuation, followed by possibly one or more word characters, which comes after a normal space and before one or more punctuations at the end of a sentence.”

If your full text is as simple as the sample text that you provided, this excessive.

This article was last modified on June 15, 2015

Comments (0)

Loading comments...