Reputation: 83
For example text
Lorem Ipsum is. simply-dummy text/of
the printing and'typesetting industry
I'd like to all the token separated by whitespace characters \s
that is in [a-zA-Z]
So the matches will be
Lorem
Ipsum
the
printing
industry
I know I can first split and then match every token using [a-zA-Z]
, but I'd like to know whether it's possible to use only 1 regular expression to achieve this.
Upvotes: 0
Views: 478
Reputation: 163362
You can assert whitespace boundaries to the left and right using negative lookarounds asserting not a non whitespace char.
(?<!\S)[a-zA-Z]+(?!\S)
Upvotes: 1