a regexp question

C. Abney cabney at ucsd.edu
Fri May 9 14:43:03 CDT 2003


~sdpm~
On Fri, 2003-05-09 at 10:45, John Chung wrote:
> I want to do a simple substitution in html files where I 
> can append some string to URL's (inside anchor tag).

Your code does more than simple substitution, it deletes everything not
in the parens.  Maybe that's what you want.

> while (<>) {
> 	s/href="([^"])+"/appendit($1)/eg;
> 	print $_;
> }

maybe perldoc perlrequick to start.
perldoc perlintro (header Regular Expressions)
perldoc perlfaq6
perldoc perlretut

The parens enclose only one character, one that is not a double-quote. 
The plus is looking for one or more copies of that character?

You need something more like:

s/(href=")(.*?)"/$1$2&sid=blah"/

Yours,

Charles
-- 
Charles Abney
Polymorphism Research Laboratory, 0603
UCSD School of Medicine
9500 Gilman Dr.
La Jolla, CA 92093-0603
~sdpm~

The posting address is: san-diego-pm-list at hfb.pm.org

List requests should be sent to: majordomo at hfb.pm.org

If you ever want to remove yourself from this mailing list,
you can send mail to <majordomo at happyfunball.pm.org> with the following
command in the body of your email message:

    unsubscribe san-diego-pm-list

If you ever need to get in contact with the owner of the list,
(if you have trouble unsubscribing, or have questions about the
list itself) send email to <owner-san-diego-pm-list at happyfunball.pm.org> .
This is the general rule for most mailing lists when you need
to contact a human.




More information about the San-Diego-pm mailing list