From: "Erik Bågfors" Date: 2002-06-10T21:01:26+09:00 Subject: Re: words[0] ! =~ /#*/ doesn't match "#aaaaaaaaa" On Sat, 2002-06-08 at 05:57, Peter Booth wrote: > > I am attempting to parse the following file and ignore lines that begin with > a # > but my regexp doesn't seem to match correctly. Can anyone tell me the > "right" way > to match a string that begins with a # character? > > Peter Booth > > > IO.foreach("C:/apps/workspace/web/build/zoneinfo.db") do |line| > words = line.split("|") > if words.length == 3 && words[0] != "realm" && words[0] ! =~ /#*/ > realm, zone, hostlist = words[0], words[1], words[2] > For easier reading of the code I suggest doing like the following IO.foreach(.............) do line next if line =~ /^#/ do_the_rest end Then you can ignore the #-lines in every line of code after the first line. /Erik -- Erik B�gfors | erik@bagfors.nu Supporter of free software | GSM +46 733 279 273 fingerprint: 6666 A85B 95D3 D26B 296B 6C60 4F32 2C0B 693D 6E32