I found a weird webpage that has link targets that include quotes in the fragment part (after the #), such as
<a href="/#A "dumb-ass" fragment">. I decided to try to handle links like that for my site mapper. Basically, I'm considering everything in an anchor tag from the first quote to the last to be the target when there is only one equal sign. That condition isn't shown below. Below is the regex I've been using to delete the quotes within the fragment portion of a target. I've tried it with and without the c modifier. Why does it only delete the quote before dumb-ass when used without the "for" loop? It works perfectly, removing both inner quotes, when I include the loop, but as a stand alone regex, even with the g modifier, only one quote gets deleted. How should I be doing this? Maybe I'm just tired, but I have the feeling I don't know regexes as well as I thought I did.
for ($a=0; $a<3; $a++)
{
$line[$count] =~ s/(href\s*=\s*(["'])[^"'#]*?#[^"']*?)\2(.*\2
+\s*>)/$1$3/isgc;
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.