Re: [regexp] Warnings on Backreferences

2006-03-06 Thread John W. Krahn
Hans Meier (John Doe) wrote: > John W. Krahn am Dienstag, 7. März 2006 00.12: >>Adam W wrote: >>>JupiterHost.Net wrote: >>$text =~ s!(.*?)\((.*?)\)!$1!g; > [...] Same exact regex as above: $test =~ s{ (.*?) [(] (.*?) [)] } {$1}xmsg; > [...] >>>Can you tell me w

Re: [regexp] Warnings on Backreferences

2006-03-06 Thread Hans Meier (John Doe)
John W. Krahn am Dienstag, 7. März 2006 00.12: > Adam W wrote: > > JupiterHost.Net wrote: > $text =~ s!(.*?)\((.*?)\)!$1!g; [...] > >> Same exact regex as above: > >> > >> $test =~ s{ (.*?) [(] (.*?) [)] } > >> {$1}xmsg; [...] > > Can you tell me what the function of the squar

Re: [regexp] Warnings on Backreferences

2006-03-06 Thread John W. Krahn
JupiterHost.Net wrote: >> >>> And 'm' and 's' are ways of telling Perl how to interpret a line, right? >> >> The /m option defines what the ^ and $ anchors match but you aren't using >> those anchors. The /s option defines what . matches so your regular >> expression will match something different

Re: [regexp] Warnings on Backreferences

2006-03-06 Thread JupiterHost.Net
$test =~ s{ (.*?) [(] (.*?) [)] } {$1}xmsg; Just a .02 via an FYI :) That looks pretty cool. Using 'x' allows whitespace use, correct? Correct. And 'm' and 's' are ways of telling Perl how to interpret a line, right? The /m option defines what the ^ and $ anchors match

Re: [regexp] Warnings on Backreferences

2006-03-06 Thread John W. Krahn
Adam W wrote: > JupiterHost.Net wrote: >> >>> $text =~ s!(.*?)\((.*?)\)!$1!g; >>> >>> >>> Thanks for the help and the more streamlined regexp. >> >> >> An even better way (see O'reilley's "Perl Best Practices" by Damian >> Conway - buy this book you will write better code) >> >> Is to make it

Re: [regexp] Warnings on Backreferences

2006-03-06 Thread John W. Krahn
JupiterHost.Net wrote: > Adam W wrote: >> John W. Krahn wrote: >> >>> $text =~ s!(.*?)\((.*?)\)!$1!g; >> >> >> Thanks for the help and the more streamlined regexp. > > An even better way (see O'reilley's "Perl Best Practices" by Damian > Conway - buy this book you will write better code) > > Is t

Re: [regexp] Warnings on Backreferences

2006-03-06 Thread Adam W
JupiterHost.Net wrote: $text =~ s!(.*?)\((.*?)\)!$1!g; Thanks for the help and the more streamlined regexp. An even better way (see O'reilley's "Perl Best Practices" by Damian Conway - buy this book you will write better code) Is to make it extremely readable with xms :) Same exact

Re: [regexp] Warnings on Backreferences

2006-03-06 Thread JupiterHost.Net
$text =~ s!(.*?)\((.*?)\)!$1!g; Thanks for the help and the more streamlined regexp. An even better way (see O'reilley's "Perl Best Practices" by Damian Conway - buy this book you will write better code) Is to make it extremely readable with xms :) Same exact regex as above: $test =~

Re: [regexp] Warnings on Backreferences

2006-03-06 Thread Adam W
John W. Krahn wrote: Adam W wrote: Here is an example of one of my regexps that produces this warning: $text =~ s!(.*?)(\()(.*?)(\))!\1<\/a>!g; BTW, why capture $2 and $4 if you are not using them and why is everything backslashed? Since I'm relatively new to the language, most of my reg

Re: [regexp] Warnings on Backreferences

2006-03-06 Thread John W. Krahn
Adam W wrote: > Hello All, Hello, > I'm using '-w' like any good hacker, but every time I try to use > backreferences in my regexps, I get a warning "\1 better written as $1 > at" > > I'm confused because, according to perlretut: > "Although $1 and \1 represent the same thing, care shoul

[regexp] Warnings on Backreferences

2006-03-06 Thread Adam W
Hello All, I'm using '-w' like any good hacker, but every time I try to use backreferences in my regexps, I get a warning "\1 better written as $1 at" I'm confused because, according to perlretut: "Although $1 and \1 represent the same thing, care should be taken to use matched variable