Perl regex: Extract values after hypen and before backslash -
i have input data in following format:
abcd-abcd abcd-abcd/efgh-1 abcd-abcd/efgh-1/ijkl-9 abcd-abcd/efgh-1/ijkl-9/mnop-432 abcd-abcd/efgh-1/ijkl-9/mnop-432/qrst-c20-blatt-4
i want extract below values values above.
abcd abcd,1 abcd,1,9 abcd,1,9,432 abcd,1,9,432,c20-blatt-4
you can use following regular expression:
(?:\/?[a-z]+-([^\/\n]+))
see demo on regex101.
this work if have homogenous input data.
$str = "abcd-abcd/efgh-1/ijkl-9/mnop-432/qrst-c20-blatt-4"; @myarray = ($str =~ /(?:\/?[a-z]+-([^\/\n]+))/g); print join(",", @myarray) . "\n";
output:
abcd,1,9,432,c20-blatt-4
Comments
Post a Comment