0

This is my test input string

Test code <div>Testing here. Div contents</div> Blah Blah <div>Second div</div>Blah

I need to capture the contents between . Please help me understand how to build the regex to accomplish this with some explanation?

asked Jul 11, 2020 at 12:44

1 Answer 1

2

I think this will work.

(?<=<div>).*?(?=<\/div>)

demo - https://regex101.com/r/vnfpRV/1

answered Jul 11, 2020 at 13:23
4
  • Yes, this is finding the match. Could you please write a few lines on how you built this regex. Thanks Kaushik. Commented Jul 11, 2020 at 14:40
  • Just want to know what does '?<=' do? Commented Jul 11, 2020 at 15:48
  • @CodeForGood I provided a demo link, where you can see the explanation for this regex at right side. Commented Jul 13, 2020 at 5:27
  • ?<= is for positive look behind. refer this link for understand what is "Positive and Negative Lookbehind ". regular-expressions.info/lookaround.html Commented Jul 13, 2020 at 5:46

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.