Thread: Regex examples
View Single Post
Old 10-10-2013, 04:46 PM   #289
theducks
Grand Sorcerer
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 15,259
Karma: 6020309
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
Quote:
Originally Posted by LuCouto View Post
Hi there,

I'm looking for a Regex expression in order to automatically generate IDs !

So, I actually have the following code:
Code:
<sup>8</sup>
That must become an ID as:
Code:
<a id="note8">8</a>
Please note that the number must be used twice !

Is there a simple way to do this with Regex ? (I've 1232 IDs to generate!)

TIA,
you can use the capture replace as many times as you wish
<sup>(\d+)</sup>
Code:
<a id="note\1">\1</a>
theducks is offline   Reply With Quote