Re: Regex problem.

Quoth Ash <ashishrai@xxxxxxxxx>:
A B B c A c B d A A

I have a string as represented above. They are separated by spaces of
unknown length. I need to match As and Bs and store them in array in
the order they occur, or as they occur. The array filled from above
string should contain: ABBABAA.

The split function on spaces cannot be used because A,B and Cs are
representative of bigger string which may itself contain spaces for
example A may represent "clever fox" and B may represent "jumps over"
in which case the sequence ABB becomes "clever fox jumps over clever
fox",so space cannot be used as delimiter.
Global matching also cannot be used because it doesn't give me the
order different pattern occur.

Err... it does for me:

~% perl -le'$_ = "clever fox jumps over foo bar clever fox";
print for /(clever fox|jumps over)/g'
clever fox
jumps over
clever fox