Thread: Regex examples
View Single Post
Old 10-10-2013, 03:46 PM   #289
theducks
Well trained by Cats
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: 29,781
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
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 online now   Reply With Quote