![]() |
Available news archives:
comp.lang.tcl
-
comp.lang.python
-
comp.security.firewalls
-
sci.crypt -
comp.lang.php -
comp.lang.javascript
|
|
comp.lang.javascript archiveRe: regular expression from variable
From: RobG <rgqld@iinet.net.au>
Date: Mon Aug 22 2005 - 14:13:18 CEST
Martin John Brindle wrote:
function searchFor( s, str ) {
will return true for: searchFor( 'be', 'beach')
To match a word exactly, use:
var re = new RegExp( '\\b' + s + '\\b' );
Now:
searchFor( 'be', 'let it be') // returns true
To make the test case insensitive:
var re = new RegExp( '\\b' + s + '\\b', 'i' );
etc.
-- RobReceived on Mon Oct 24 02:14:18 2005 |