I'm not sure what language you're looking for, but in Ruby you can just use [String#split
][1] (and you don't need a regexp, a simple string parameter will do):
>> strings = ["kev-+kvs+-one-+gdl+-greg-+kvs+-two-+gdl+-les-+kvs+-three",
"-+gdl+-kev-+kvs+-one-+gdl+-greg-+kvs+-two-+gdl+-les-+kvs+-three",
"kev-+kvs+-one-+gdl+-greg-+kvs+-two-+gdl+-les-+kvs+-three-+gdl+-"]
>> split = strings.map {|s| s.split "-+gdl+-"}
=> [["kev-+kvs+-one", "greg-+kvs+-two", "les-+kvs+-three"],
["", "kev-+kvs+-one", "greg-+kvs+-two", "les-+kvs+-three"],
["kev-+kvs+-one", "greg-+kvs+-two", "les-+kvs+-three"]]
Note that this does have the problem of introducing null fields at the beginning or in the middle of your string. If you don't want any null fields, you'll probably have to filter those out afterwards:
>> split.map {|a| a.reject {|s| s == ""}}
=> [["kev-+kvs+-one", "greg-+kvs+-two", "les-+kvs+-three"],
["kev-+kvs+-one", "greg-+kvs+-two", "les-+kvs+-three"],
["kev-+kvs+-one", "greg-+kvs+-two", "les-+kvs+-three"]]
If you're not familiar with ruby, the map
part is simply applying the same thing to each item in the array, so I can demonstrate how this applies to all of our examples.