0

I have a regex which searches successfully for a text inside an HTML code given a keyword however I cannot get rid of the symbol < or >

This is my regex:

[><][^><=]*climate[> - <][^<|//]*

And this the result:

>Formation of coastal sea ice in North Pacific drives ocean circulation and climate<

any suggestion please?

Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
jim
  • 3
  • 1

2 Answers2

0

Just use [^<>]*climateas regex, that should do the trick. Or did I misunderstand your question?

Nice helper for testing and building regex: http://regexr.com/

Kai Adelmann
  • 199
  • 6
  • 15
0

Add look ahead and lookbehind instead of matching them:

(?<=[><])[^><=]*climate(?=[> - <])[^<|/]*
^^^^^^^^^              ^^^^^^^^^^^

See DEMO

karthik manchala
  • 13,492
  • 1
  • 31
  • 55