Regular Expressions 101

Community Patterns

Pull Words from Sentence

0

Regular Expression
Java 8

"
(?<ApWord>((\w+)(')(\w+)))|(?<HyWord>((\w+)(-)(\w+)))|(?<Rest>\w+)
"
gm

Description

Simple little regex to pull words out of a sentence. Obviously \w+ exists, but this accounts for a few corner cases that would normally be missed. Things like let's or ten-four good-buddy.

Submitted by Tony B. - 3 years ago