in reply to Help with regex
Hi, you need to make the optional part optional:
Hope this helps!perl -Mstrict -wlE ' my @str=("w7R9Kstc017510: split:","w7R9Kstc017510[1]: split:","w7R9Kst +c017510[2]: split:"); for (@str) { say "$_ matches" if /(\w+)(?:\[\d+\])?: split:/ # here ^ } ' w7R9Kstc017510: split: matches w7R9Kstc017510[1]: split: matches w7R9Kstc017510[2]: split: matches
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Help with regex
by bangor (Monk) on Sep 04, 2018 at 23:20 UTC | |
by haukex (Archbishop) on Sep 05, 2018 at 19:16 UTC |