2

I'm trying to generate a RegEx that grabs all the content in between "<" and ">" and stops if it finds a "|". For example:

This is the link <stackoverlflow.com>
This is the link <https://stackoverlflow.com>
This is the link <stackoverlflow.com | Click here>
This is the link <https://stackoverlflow.com | Click here>

I tried with something like this but it doesn't work: ((?!<)[^\s]+((?=>)|(?=\|)))
Can you help me here?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
David
  • 63
  • 5

1 Answers1

1

You may use

(?<=<)[^<>\s|]+

See the regex demo

Details

  • (?<=<) - a location immediately preceded with <
  • [^<>\s|]+ - 1 or more chars other than <, >, whitespace and |.
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563