[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] help?



Hi,

I'm trying to figure out a regular expression, and any help I could get
would be greatly appreciated. What I'm trying to do is manipulate a word
in string. Not any word, mind you, but sometimes the first, other times
the fifteenth, another time the eleventh. Finding the word and it's
'number' in a string is fine, but getting to it via a regexp is my
problem.

For a sample:
$x = "a a a a a a a";
$x =~ /((a )\2)/$1jackass /;
This does what's intended (sort of).

None of these work, however. I know why, but I thought I'd throw these
in just to show where I've been:
$x = "a b c d e f g";
$x =~ /((\w )\2)/$1jackass/;
or
$x =~ /(([a-z] )\2)/$1jackass/;
or
$x =~ /((. )\2)/$1jackass/;

Also, if I change the backreference '\2' to \3 or \4 or whatever,
MacPerl crashes... what am I doing wrong? Help!


Thanks,
Kevin

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch