I need to replace 'aa' with 'a' in a string if 'aa' occurs at the end of the word. But the characters in the string could be separated by meta data of the form: <meta_data>, where meta_data could be anything.
Please look at this snippet of code. My goal is to check if there is a character following 'aa'. When I execute this code, the "if" loop is entered. I would think the 'r' would fail a match at(^a-zA-Z*) and the if block won't be entered.
my $in_str = 'aa<c><d>r'; if ($in_str =~ /^aa((<[^>]*>)*)([^a-zA-Z]*)/) { print "Found 1: $1\n"; print "Found 2: $2\n"; print "Found 3: $3\n"; }
In reply to Regex question - capturing next char by perluser4102
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |