Bareword found where operator expected at -e line 3, near "] String0" (Missing operator before String0?) Bareword found where operator expected at -e line 4, near "] String1" (Missing operator before String1?) Bareword found where operator expected at -e line 5, near "] String2" (Missing operator before String2?) Bareword found where operator expected at -e line 6, near "] String3" (Missing operator before String3?) Bareword found where operator expected at -e line 7, near "] String4" (Missing operator before String4?) Bareword found where operator expected at -e line 8, near "] String5" (Missing operator before String5?) Bareword found where operator expected at -e line 9, near "] String6" (Missing operator before String6?) Bareword found where operator expected at -e line 10, near "] String7" (Missing operator before String7?) syntax error at -e line 3, near "] String0" Execution of -e aborted due to compilation errors.
To get all the matches from the m// operator, you need list context (which you already have), but also the /g option:
my @matches = $initialStr =~ /\d+:\d+:\d+/g;
Or, to get closer to your desired output:
my @matches = $initialStr =~ /\[ .*? \] \s* ( \[ .*? \] .* )/gx;
In reply to Re: regex remove blank/whitespace until first occurrence of specific character "["
by choroba
in thread regex remove blank/whitespace until first occurrence of specific character "["
by thanos1983
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |