Hey folks,
Normally I've pretty much solved my RE manupulation but somehow I'm blowing this one...
Trying to replace spaces with underscore on text strings which are enclosed in quotes.
want
<tr>
<td><a href="3d graphic.htm">3d graphic</a></td>
</tr>
<tr>
<td><a href="acrobat pdf.htm">acrobat pdf</a></td>
</tr>
To end up
<tr>
<td><a href="3d_graphic.htm">3d graphic</a></td>
</tr>
<tr>
<td><a href="acrobat_pdf.htm">acrobat pdf</a></td>
</tr>
I've focused on the quotes so that the other text is untouched.
I've tried the [:space:] and [:blank:] with no success. I give...help!
K
Replace spaces within text strings
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
Jörg Frech
Re: Replace spaces within text strings
Hi Kenny,
just use a macro:
1) Search for "[^"]+"
(including all the quote characters)
2) Replace <space> by _
(replace all, in selected text)
You can run this macro using multi-play, with "repeat to end of file" selected.
Jörg
just use a macro:
1) Search for "[^"]+"
(including all the quote characters)
2) Replace <space> by _
(replace all, in selected text)
You can run this macro using multi-play, with "repeat to end of file" selected.
Jörg
-
Kenny
Re: Replace spaces within text strings
Maybe I'm getting this wrong, but this replaces my whole string with a single underscore character. Am I making a procedural error?
I forgot to mention also that there may be multiple occurances of a space within each quoted string.
So basically, I'm trying to select all of the spaces within each string, and change them to underscore characters, leaving the rest of the string characters, including the quotes, intact.
I thought that taking the weekend to stew on this would make it easier to solve, but it didn't. This is emabarrassing...
I forgot to mention also that there may be multiple occurances of a space within each quoted string.
So basically, I'm trying to select all of the spaces within each string, and change them to underscore characters, leaving the rest of the string characters, including the quotes, intact.
I thought that taking the weekend to stew on this would make it easier to solve, but it didn't. This is emabarrassing...
-
Jörg Frech
Re: Replace spaces within text strings
I just checked it and it works fine. The first step selects the text between any two quotes on the same line. The "Replace <space> by _" really means a space character in the "Find what" box and an underscore character in the "Replace with" box. Since the text between the quotes will be selected, only spaces between the quotes will be replaced. If you include a "cursor right" as a third step, then it works for multiple strings on one line, too. Anyway, I'll send you the macro by email.
-
Kenny
Re: Replace spaces within text strings
You're right, your macro works perfectly.
Now, I am trying to sort out what I've done wrong with my own macro. By your description it should have worked fine.
Anyway, thanks for hanging in there with me on this.
K
Now, I am trying to sort out what I've done wrong with my own macro. By your description it should have worked fine.
Anyway, thanks for hanging in there with me on this.
K