I'm using a non-capturing grouping which seems to be capturing.
I expect the code
(?:|([^]]+))? to
not capture the pipe character, but it does.
Code:
#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;
use URI;
my $text = <<END;
this is some plain text
here is a link: [link://forum] and here is another:
[mentors://pil_description|Partnerships in Learning]
END
$text =~ s!
\[
(\w+)
://
([\w-]+)
(?:|([^]]+))?
\]
!print("'$1' '$2' '$3'\n")!gsex;
Output:
'link' 'forum' ''
'mentors' 'pil_description' '|Partnerships in Learning'
Use of uninitialized value in concatenation (.) or string at test.pl l
+ine 13.
Are any of my modifiers (/gsex) affecting the capturing, or is there anything else I'm missing?