F.P
F.P

Reputation: 17831

Regex matchin string that containts at least one specific character

I'm trying to create an expression that matches anything between two whitespaces that does contain at least one - but have no f** idea how to do that.

Trying things like (?<=\s)[A-Z0-9(\-)+]+(?=\s) don't work at all...

Has anybody a good idea?

Upvotes: 0

Views: 103

Answers (1)

Manu
Manu

Reputation: 29163

Try

(?<=\s)\S*-\S*(?=\s)

You might not even need the look ahead/behind:

\S*-\S*

may work just fine

Upvotes: 3

Related Questions