Reputation: 25
my testsentence is for example 'hello random-word testing'
I would like to find the regular expression to extract 'random word' but explude the dash ('-')
I tried [a-z]+[^-][a-z]+, but this also selects the words in front and at the end
Thanks
Upvotes: 1
Views: 28
Reputation: 7573
You could do it like this
([a-z]+)[-]([a-z]+)
At that point $1
and $2
will contain your words. Alternatively
([a-z]+[-][a-z]+)
At that point, just do a replace on $1
for '-' -> ' '
Upvotes: 1