in reply to Match Optional Groups with 1 Required Group

I just realized I could probably use split and then validate each one. However, I'm still open to a regex solution.
  • Comment on Re: Match Optional Groups with 1 Required Group

Replies are listed 'Best First'.
Re^2: Match Optional Groups with 1 Required Group
by Laurent_R (Canon) on Feb 04, 2014 at 07:15 UTC
    Using the split function is exactly what I was going to suggest after having read your original post since it is particularly appropriate for text chunks delimited by separators (although a capturing regex can of course also do it, as shown in the posts below). As a side note, have a look at predefined character classes, such as \w, which can save you quite a bit of typing and make your regexes easier to read and understand.