Regex to match the first ending HTMl tag

前端 未结 3 451
醉酒成梦
醉酒成梦 2021-01-14 21:00

I am trying to write a regex which match the first ending form tag.

  [^~]* 

The above regex

3条回答
  •  走了就别回头了
    2021-01-14 21:19

    Just make the pattern non-greedy so that it matches the smallest possible amount of characters instead of the largest possible:

    ]*name="loginForm"[^>]*>[^~]*?
    

    Edit:
    Changed .* to [^>]* in the form tag, so that it doesn't match outside the tag.

提交回复
热议问题