javascript - regex jquery to replace number with link -
i have page of database results users type in reference post. (the database day event tracker scheduling office).
the reference other post posts id (format of 001234). uses these match events dockets , other paperwork truck drivers. 6 digit number on own.
<div class="eventswrapper"> data db output here using php in foreach loop. presents data in similar fashion facebook example. </div>
what need once data in above div loaded, go through , replace every whole 6 digit number (not part of number) number hyperlink.
it important looks number space either side:
eg: ref 001122 <- - not -> ignore ab001122
once have hyperlink tag can make reference number clickable take users directly post.
i not regex think like:
\b(![0-9])?\d{6}\b
i have no idea how search div , replace regex hyperlink. appreciate help.
(?:^| )\d{6}(?= |$)
you can use , replace <space><whateveryouwant>
.see demo.
https://regex101.com/r/bw3ar1/7
\b
wont works cos a1
not word boundary
want.
Comments
Post a Comment