Here's one I am guessing WE can do with this look-ahead thing, which I would like to learn if someone will show an example. This is a case where I could have used it. I did a search and replace for every other case of "&"; replace with "&"
<tr>
<td class="dbdr">&#7749;</td>
<td class="dbdr">¼</td>
<td class="dbdr">lc n underdot</td>
<td class="dbdr">1E47</td>
<td class="dbdr">&#7749;</td>
<td class="dbdr">.n</td>
</tr>
<tr>
<td class="dbdr">&#209;</td>
<td class="dbdr">½</td>
<td class="dbdr">Cap N tilda</td>
<td class="dbdr">00D1</td>
<td class="dbdr">&#209;</td>
<td class="dbdr">~N</td>
</tr>
<tr>
<td class="dbdr">&#241;</td>
<td class="dbdr">¾</td>
<td class="dbdr">lc n tilda</td>
<td class="dbdr">00F1</td>
<td class="dbdr">&#241;</td>
<td class="dbdr">~n</td>
</tr>
Regex help: look ahead
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
Here's a starting point:
with '.' does not match a newline character not selected.
This will fail if there's more than one section for the same character entity. And it will be rather slow on large input. Better to specify the context more narrowly, without a newline-inclusive .* repeatedly trying to run to the end.
Code: Select all
&(?=(#[0-9]+;).*\1)
This will fail if there's more than one section for the same character entity. And it will be rather slow on large input. Better to specify the context more narrowly, without a newline-inclusive .* repeatedly trying to run to the end.
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
It's saying:mo wrote:OK I think I see what it is saying now.
Code: Select all
match:
& "&" literally
(?= if it's followed by
( (beginning of marked bit)
#[0-9]+; a hash, a digit sequence, a semicolon
) (end of marked bit)
.* anything (expensive)
\1 a copy of whatever matched the marked bit
)
In this case, lookahead seems unnecessary:
Find
<tr>\n<td class="dbdr">&
Replace
<tr>\n<td class="dbdr">\&
should be possible to do this in Textpad.
If you want to replace the second occurrence of a row, use
Find
&(#[0-9]+);</td>\n<td class="dbdr">(.*)</td>\n</tr>
Replace by
\&\1;</td>\n<td class="dbdr">\2</td>\n</tr>
Btw, why do you set a class for each td?
Why not set it for the whole table (or, if there are other rows in the table, for the tr)?
Then, instead of
td.dbdr
you could use
table.dbdr td
or
tr.dbdr td
as CSS selector.
Find
<tr>\n<td class="dbdr">&
Replace
<tr>\n<td class="dbdr">\&
should be possible to do this in Textpad.
If you want to replace the second occurrence of a row, use
Find
&(#[0-9]+);</td>\n<td class="dbdr">(.*)</td>\n</tr>
Replace by
\&\1;</td>\n<td class="dbdr">\2</td>\n</tr>
Btw, why do you set a class for each td?
Why not set it for the whole table (or, if there are other rows in the table, for the tr)?
Then, instead of
td.dbdr
you could use
table.dbdr td
or
tr.dbdr td
as CSS selector.
MudGuard,
I see the method you are suggesting; nevertheless I'm glad I asked about look-ahead; I'm sure this will be useful.
I'm still not sure if I could do what I want your way though. I want a border around each cell. It was my understanding that this should be done at the <td> level.
I see the method you are suggesting; nevertheless I'm glad I asked about look-ahead; I'm sure this will be useful.
Truth is I've been learning this whole thing (if not my entire life) just sufficiently to get done what I want to get done. CSS was a major leap for me and I was happy to get anything that did what I wanted and passed the validators.Btw, why do you set a class for each td?
Why not set it for the whole table (or, if there are other rows in the table, for the tr)?
I'm still not sure if I could do what I want your way though. I want a border around each cell. It was my understanding that this should be done at the <td> level.
Best Wishes!
Mike Olds
Mike Olds