Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Regexp. Combination of words block. Need help.

by Corion (Pope)
on Feb 09, 2020 at 10:47 UTC ( #11112672=note: print w/replies, xml ) Need Help??

in reply to Regex. Combination of words block. Need help.

Why do you need to do this all in one regular expression?

Also, do you mean that the space in front of  ccc should be treated differently from the space between abc Qwerty?

Also, why does Qwerty not show up as a separate string in your other examples?

If you want a simple approach, just split the string on /[;,\s]+/ to get an array, and then get all the sub-sequences of that array:

#!perl use strict; use warnings; my $string = 'aaa, bbb, ccc,ddddd;eee-12345abc Qwerty'; my @items = split /[,;\s]+/, $string; for my $i (0..$#items) { for my $j ($i..$#items) { print join " - ", @items[ $i .. $j ]; print "\n"; }; } __END__ aaa aaa - bbb aaa - bbb - ccc aaa - bbb - ccc - ddddd aaa - bbb - ccc - ddddd - eee-12345abc aaa - bbb - ccc - ddddd - eee-12345abc - Qwerty bbb bbb - ccc bbb - ccc - ddddd bbb - ccc - ddddd - eee-12345abc bbb - ccc - ddddd - eee-12345abc - Qwerty ccc ccc - ddddd ccc - ddddd - eee-12345abc ccc - ddddd - eee-12345abc - Qwerty ddddd ddddd - eee-12345abc ddddd - eee-12345abc - Qwerty eee-12345abc eee-12345abc - Qwerty Qwerty

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11112672]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2020-06-03 09:42 GMT
Find Nodes?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?

    Results (22 votes). Check out past polls.