I'm writing a program that would take a line of text, match on a word that would end in 'a' and also capture up to the next 5 characters. Here is the program.
r/bin/perl use v5.12; use warnings; ## 9/26/19 ## Program uses named captures instead of $1 chomp(my $text = <STDIN>); while (<>) { # take one input line at a time chomp; if ( $text =~ m/((?<word1>\b\w*a\b))(?<word2>\s+++++))/) { print "Matched: |$`<$&>$'|\n"; # the special match vars print " 'word' contains '$+{word1} $+<word2>'\n"; } else { print "No match: |$_|\n"; }
and here is the errors that I'm getting
Nested quantifiers in regex; marked by <-- HERE in m/((?<word1>\b\w*a\ +b))(?<word2>\s+++ <-- HERE ++))/ at ./Chapter8_Exer5 line 12
TIA The catfish
In reply to Trying out 2 captures by catfish1116
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |