From: Dossy Date: 2002-06-08T13:04:16+09:00 Subject: Re: words[0] ! =~ /#*/ doesn't match "#aaaaaaaaa" Use /^#/ and not /#*/ -- these are regular expressions, not globbing or shell wildmat ... -- Dossy On 2002.06.08, 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] > > > > qatest|dmz|nbigqsa02 > qatest|ndmz|nmigqsa06 > #qatest|tools|nycmqsa01,nycmqsa02 > #qatest|ficc|nwwpqsa01 > > -- Dossy Shiobara mail: dossy@panoptic.com Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70)