From: dblack@... Date: 2003-02-13T00:18:16+09:00 Subject: Re: Need regex help (or bug in match) Hi -- On Thu, 13 Feb 2003, Jim Freeze wrote: > Hi > > I seem to be having a problem with match and I can't figure > it out. It's either a bug or I am doing something stupid > and can't see the forest for the trees. > > Can regex guru help me out here? > Thanks > > FETCH_DATA_HDR = /\[([^]]*)\]/ > > PUSH_DATA_HDR = Proc.new { |line| > m = FETCH_DATA_HDR.match(line.strip) > a = m[1].split(/\s*,\s*/, 2) > hdr = [] > p a > hdr << {:X_VAR_NOM => a.shift} > p a > p a[0] > s = /^([^(]*)\(/.match(a[0]) > puts /Vg/ =~ a[0] #=> nil > p s[1] #=> Vg # How can this match Vg when /Vg/ =~ a[0] == nil? > } > > line = "[Vgs, Id(Vbs=0.0E+00), Id(Vbs=-4.5E-01), Vds=1.0E-01, Ref_Vs=0]" > PUSH_DATA_HDR.call(line) I get Id, not Vg, for s[1]. David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav