What's going wrong at the moment is this: some of your links have the 'group' parameter, some don't. Consider the case of one which doesn't, followed by one which does. So the text is
Your first match will be<a href="http://www.foo.com/">Foo</a> wibble <a href="http://www.bar.c +om/" groups="1,2,3">Bar</a>
i.e. the problem is that if a tag *doesn't* have the 'group' parameter, then the first .* will swallow all the text until it can find$1= http://www.foo.com/">Foo</a> wibble <a href="http://www.bar.com/ $2= 1,2,3 $3= Bar
which will be in the *next* 'a' tag that *does* have a 'group'." group= etc...
Even without dot star, this solution isn't too robust - what if the someone misses out a quote mark (and people will in HTML)? You might want to think of a different WTDI.
andy.
update: and physi is right, you either need to escape the slash e.g. <\/a> or use a different delimiter for your regexp e.g. s#original#substitute#isge
update2: have a look at HTML::Parser and maybe template toolkit. Any monks have other ideas?
update3: Text::TagTemplate? (never used it though, don't know if it's any good) - you could use this module to define your own tag e.g. <#GROUPLINK href="http://whatever.com" group="1,2,3" text="click here for link"> so that it called your change() subroutine when it found the special tag. Then the module would parse the HTML for you.
The reason why it's a good idea to get a module to parse the HTML for you is that it's surprisingly difficult to do correctly. E.g. what if the tag is inside a comment? what if the tag reads <a group="1,2,3" href="whatever">? If you're going to be the only one writing the HTML, then you're probably OK with a regexp - otherwise you probably do need to use a module. In any case, good luck with it. andy.
In reply to Re: regex and dot to star
by andye
in thread regex and dot to star
by LiTinOveWeedle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |