md123
md123

Reputation: 325

REGEX: Select matches in between two slashes?

I want to select words that have slashes in between them, so not just slashes alone.

I'm using this code: (/.+?/), but that doesn't work

Full string:

COOL /RE/
COOL RE
/

I'm trying to get word from first line only. /RE/

Upvotes: 2

Views: 400

Answers (2)

zr0gravity7
zr0gravity7

Reputation: 3194

Since you mentioned you want "words", I think the pattern would be

/\w+/

If you wanted to only capture the word between the forward slashes, use a capture group:

/(\w+)/

Upvotes: 2

Emma
Emma

Reputation: 27723

Maybe,

/\S+/

might simply work.

Demo

Upvotes: 0

Related Questions