From: Chris Date: 2002-04-04T05:50:13+09:00 Subject: Re: regular expression question In article <46487A0D3619D511BF860000F6B99827D2C177@PRESGGS17>, "Firestone, Mark - Technical Support" wrote: > Regular expressions give me a headache.. They're fun that way... I decided to think about this a little, and decided to come up with something a bit more robust, that would ignore a semi-colon enclosed in a string or regexp. So far the following seems to work. class String def code_split re = /(([^;"'\/]+)|([^;]*((["'\/])[^\5]*\5)[^;]*));+/ deal_with = self.clone deal_with += ";" unless deal_with =~ /;+$/ matches = [] while deal_with =~ re matches << $1 deal_with.sub! $1, "" end matches end end str = "hello_world;a = 'foo bar';b = \"hello ; world\"" p str.code_split