Getting Strings Before and After a Keyword

Hey Scott,

Simple?...  :sunglasses:

Parsing text is an exacting business – especially when you're tying to accommodate different possible inputs.

In a case like this the smart thing to do is generally let go of the idea of writing the perfect regular expression and preprocess the text with a different regex.

Something like this which will remove all text from a period to the end of the string.

Find:

\..+$

Replace:

Nothing

You could change that to:

[.!?].+$

To accommodate more punctuation marks.

-Chris

1 Like