4672Re: [edit+] Search and replace with match
- Jun 13, 2006
----- Original Message -----
Sent: 6/13/2006 10:43:46 AM
Subject: [edit+] Search and replace with match
> I've got groups of radio buttons named like this:
> <td><input type=radio name=rad1 value=4></td>
> <td><input type=radio name=rad1 value=3></td>
> <td><input type=radio name=rad1 value=2></td>
> <td><input type=radio name=rad1 value=1></td>
> Goes from rad1 to rad45 groups.
> and I'd like to change the "rad" to "Question" but keep the number, ie:
> rad1 group turns into Question1 group.
> I can match the "rad" with this: name=rad*[0-9] but how do I do a
> replace that keeps the radio button group number?
Use parentheses to group the matches:
That will hold the first grouped match in \1 and the second one in \2, and replaces it with the first match, followed by the string "Question, followed by the second match; so that "name=rad1", say, turns into "name=Question1".
P.S. The '*' symbol goes on the right of the digit range to signify 0 or more digits. As you put it, it means "0 or more 'd's", so it will match "rad1", "ra3", and "raddddddd3".
- Next post in topic >>