perl question

mike h foobar at u.washington.edu
Sun Feb 27 22:42:56 PST 2000


Oops, the "$" would cause you to match a newline at the end of the 
value, so 'lin\n' would match below...hehe.

-----------------------------------------------
Michael Hornung		foobar at u.washington.edu

On Sun, 27 Feb 2000, mike h wrote:

|You didn't say what the fields could contain...  Parker's example could
|work, but it could also give false positives if there's a chance you'll
|have values containing a space...a more precise regexp would be:
|	/^lin$/
|This will match 'lin' but not 'linux', 'edlin', 'vio lin',
|'lin guist', or 'lin\n'.  You need to be careful in considering what all
|of the possibilities are before selecting your regular expression, else
|you'll have trouble down the road.
|
|-----------------------------------------------
|Michael Hornung		foobar at u.washington.edu
|
|On Sun, 27 Feb 2000, Parker Thompson wrote:
|
||
||Try this:
||
||$input =~ /\blin\b/;
||
||This will match lin but not linux or gamblin. The \b char requires that
||there be a word boundary for the reg exp to be true.
||
||Check out the section on regular expressions in Programming Perl, it's
||straight-up dope-fly.
||
||Parker.
||-----------------------------------------------------------------------
||"It took the computing power of three C-64s to fly to the Moon.
||It takes a 486 to run Windows 95. Something is wrong here."
||
||On Sun, 27 Feb 2000, Greg Daly wrote:
||
||:hey all,
||:not explicitly linux, but close. i'm trying to match occurences of a
||:string in perl. problem is, i only want occurences of that string
||:specifically to ring a true. example, say i have this list:
||:
||:linux
||:linus
||:
||:$input=~/lin/  will give me a TRUE, even though I only want it to ring
||:true IFF there exists an entry named 'lin'. 
||:
||:see what i mean? any suggestions? is there a switch i don't know about?
||:thanks,
||:-greg
||:
||:
||:
||:
||
||
|
|



More information about the Linux mailing list