Re: regex help - only one value returned
[email protected] (Gary Stainburn)
| Newsgroups | perl.beginners |
|---|---|
| Message-ID | <[email protected]> |
On 02/12/2020 13:56, Vlado Keselj wrote:
> Well, it seems that the first one is what you want, but you just need to
> use $1 and ignore $2.
>
> You do need parentheses in '(mr|mrs|miss|dr|prof|sir)' but if you do not
> want for them to be captured in $2, you can use:
> '(?:mr|mrs|miss|dr|prof|sir)'. For example:
>
> print "match3='$1' '$2'\n" if
> ($T=~/^((?:mr|mrs|miss|dr|prof|sir) .{5,}?)\n/smi);
>
> would give output:
>
> match3='Miss Jayne Doe' ''
Perfect, thank you.
I can't ignore $2 as it's in a loop with other regex that genuinely
returns multiple matches. The amendment to the REGEX worked perfectly.
Gary