Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi, i'm trying to resolve a regex problem. I'm trying to use a backreference but don't know how. My documentation says I should use \1(or \l?)for that. Information on the internet says it should be g1,g2 etc. But neither seems to work. I have an example. I developed this regex to print all 3-letter words:
$tekst = "hoii hoi and oi"; while($tekst=~/\b(\w\w\w)\b/g){ print "$1\n"; }
I want to change it into all 3-letter words that occur more than once. So something like:
Maybe someone can tell me the proper way to do this. Thank you in advance./\b(\w\w\w)\b\g1/g)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regex backreference
by Corion (Patriarch) on Nov 30, 2013 at 12:37 UTC | |
|
Re: regex backreference
by oiskuu (Hermit) on Nov 30, 2013 at 16:44 UTC | |
|
Re: regex backreference
by Kenosis (Priest) on Nov 30, 2013 at 16:49 UTC | |
|
Re: regex backreference
by Anonymous Monk on Nov 30, 2013 at 17:35 UTC | |
|
Re: regex backreference
by Anonymous Monk on Dec 01, 2013 at 11:57 UTC | |
by Corion (Patriarch) on Dec 01, 2013 at 13:42 UTC | |
|
Re: regex backreference
by Anonymous Monk on Dec 01, 2013 at 12:38 UTC |