0

I've got something like this

<div class="col-md-6">
<div class="form-group">
 <label class="control-label col-md-3">Expires at:</label>
<div class="col-md-9">
<p class="form-control-static">
March 3rd, 2019 </p>
</div>

I wanna capture the date. The only way i know how to do it is like this which captures the space after 2019 which i don't need.

(?<=>Expires at:<\/label>\n<div class=\"col-md-9\">\n<p class=\"form-control-static\">\n)([^<]*)
leo227
  • 21
  • 3

1 Answers1

0

Well your match condition is "all characters except <", which is literally what you get. You can either use some kind of trimming function in your language outside of the regex to post-process it, or write the regex you actually mean:

(?<=>Expires at:<\/label>\n<div class=\"col-md-9\">\n<p class=\"form-control-static\">\n)([ \w,]*?)\s*<

ie, all alphanumerical characters, numbers and commas, as few as possible, followed by as many spaces as possible (or 0), followed by <, and only capture the first part. See it in action here.

Also, obligatory reference to this post.

Blindy
  • 65,249
  • 10
  • 91
  • 131