Tuesday, May 14, 2024
 Popular · Latest · Hot · Upcoming
152
rated 0 times [  158] [ 6]  / answers: 1 / hits: 16405  / 14 Years ago, tue, april 20, 2010, 12:00:00

I am not so good with regex. I am struggling to find a solution for a small functionality.



I have a ajax response which returns a string like Your ticket has been successfully logged. Please follow the link to view details 123432.



All I have to do is replace that number 123432 with <a href=blablabla.com?ticket=123432> using javascript.


More From » regex

 Answers
22

Try this:



fixedString = yourString.replace(/(d+)/g, 
<a href='blablabla.com?ticket=$1'>$1</a>);


This will give you a new string that looks like this:




Your ticket has been successfully logged. Please follow the link to view details <a href='blablabla.com?ticket=123432'>123432</a>.



[#97016] Sunday, April 18, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
amari

Total Points: 736
Total Questions: 111
Total Answers: 90

Location: Saint Pierre and Miquelon
Member since Fri, Jan 28, 2022
2 Years ago
;