David Masover
7/19/2008 3:08:00 AM
On Friday 18 July 2008 21:59:56 Robb wrote:
> Hi all,
>
> I have input strings that can look like this:
>
> Common, Commerc(e, ial)
>
> I need to parse these into the three words that this represents:
>
> Common, Commerce, Commercial.
>
> I'm a little new to ruby, and hence wondering what direction would be
> best to go in? (.scan, regexes ... something else?) For me, the
> complication I'm not sure how to deal with is the two "levels" of the
> comma as a separator.
One way would be to find the exceptions first. Replace anything that matches
the
Commerc(e, ial)
pattern with the two words, as the literal string "Commerce, Commercial". Then
you can just do a simple split on the commas, and maybe strip whitespace.