View Single Post
Old 03-03-2010, 12:41 PM   #6
Valloric
Created Sigil, FlightCrew
Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.
 
Valloric's Avatar
 
Posts: 1,982
Karma: 350515
Join Date: Feb 2008
Device: Kobo Clara HD
Quote:
Originally Posted by HarryT View Post
In most regex implementations, the "matches" for expressions are represented in the "replace" string by "\1", "\2", etc, so to replace:

<p>nnn<p>

by

<h3>nnn</h3>

you'd use a search string of:

<p>[0-9]*</p>

and a replace string of:

<h3>\1</h3>

where the "\1" will contain whatever was matched by the "[0-9]*".
Harry, I don't know what regex flavor you are using, but all the engines that I know of require parentheses for capture groups.

So like this:

Code:
<p>([0-9]*)</p>
And then:

Code:
<h3>\1</h3>
For what Zelda wants, I'd use this:

Code:
<p>(\d+)</p>
With this:

Code:
<h3>\1</h3>
Valloric is offline   Reply With Quote