Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!hp4nl!ruuinf!cs.ruu.nl From: piet@cs.ruu.nl (Piet van Oostrum) Newsgroups: comp.lang.perl Subject: matching word boundaries with regexps Summary: Random results Message-ID: <2295@ruuinf.cs.ruu.nl> Date: 15 Jan 90 10:57:37 GMT Sender: news@ruuinf.cs.ruu.nl Reply-To: piet@cs.ruu.nl (Piet van Oostrum) Organization: Dept of Computer Science, Utrecht University, The Netherlands Lines: 28 It seems that matching word boundaries with \b in regexps doesn't work properly. I get random results. The following script should illustrate the problem. Feed it with lines of the form: vote yes (or: vote no) Or an I doing something wrong??? ---------------------------------------------------------------- #! /usr/bin/perl $yes = 0; $no = 0; $vote = 0; while () { chop; print "=$_=\n"; if (/vote/i || /comp.text.tex/i) { $vote ++; $yes ++ if /\byes\b/i; $no ++ if /\bno\b/i; } print "vote = $vote, yes = $yes, no = $no\n"; } ---------------------------------------------------------------- Piet* van Oostrum, Dept of Computer Science, Utrecht University, Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands. Telephone: +31-30-531806 Uucp: uunet!mcsun!hp4nl!ruuinf!piet Telefax: +31-30-513791 Internet: piet@cs.ruu.nl (*`Pete')