user1580348
user1580348

Reputation: 6053

How to get the text between angular brackets but without the angular brackets?

I have tried this:

(?=<).+(?<=>)

But it always matches the angular brackets too:

enter image description here

So how can I get the text without the brackets? (it should match any text between the brackets which fits in a line).

Upvotes: -1

Views: 448

Answers (1)

Jan
Jan

Reputation: 43169

It's pretty easy, the .+ eats up everything up to the end of the line (remember, the dot matches everything including > and < here).
Either use a lazy quantifier (demo)

(?<=<).+?(?=>)

or a negated character class (demo)

<([^>]+)

Upvotes: 1

Related Questions