Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #15763
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.straub-nv.de!uucp.gnuu.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail |
|---|---|
| Content-Type | text/plain; charset="UTF-8" |
| Message-ID | <1492793.DGNhQbDWfW@PointedEars.de> (permalink) |
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Reply-To | Thomas 'PointedEars' Lahn <cljs@PointedEars.de> |
| Organization | PointedEars Software (PES) |
| Date | Fri, 07 Sep 2012 15:36:23 +0200 |
| User-Agent | KNode/4.4.11 |
| Content-Transfer-Encoding | 8Bit |
| X-Face | %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v |
| Face | iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg== |
| Subject | Re: regexp help |
| Newsgroups | comp.lang.javascript |
| References | <fqydnZxNJ4Gw59TNnZ2dnUVZ_sidnZ2d@westnet.com.au> <aatr4mFvsbU1@mid.uni-berlin.de> |
| Followup-To | comp.lang.javascript |
| MIME-Version | 1.0 |
| Lines | 47 |
| NNTP-Posting-Date | 07 Sep 2012 15:36:25 CEST |
| NNTP-Posting-Host | 223ad3e2.newsspool1.arcor-online.net |
| X-Trace | DXC=e\E<QaD[=KA@Y=h<_c3PkHic==]BZ:afN4Fo<]lROoRAnkgeX?EC@@@BeLlkVT3cfDDZm8W4\YJNLR=i2=[N6Y6Jf5^:]e\1IMMjPddCj9e?kB |
| X-Complaints-To | usenet-abuse@arcor.de |
| Xref | csiph.com comp.lang.javascript:15763 |
Followups directed to: comp.lang.javascript
Show key headers only | View raw
Jake Jarvis wrote:
> On 07.09.2012 06:37, wrote Andrew Poulos:
>> I have a string
>> var str = 'This is some text.';
>>
>> Within that string I need to find whether a whole word exists. The test
>> is to be case insensitive. The word to test for is held in the var 'k'.
>>
>> When I try this:
>>
>> var k = 'SOME';
>> var myRe = new RegExp("b" + k + "b", "i");
>> var found = myRe.test(str);
>>
>> I expected 'found' to return true. What am I doing wrong?
>
> You are not escaping the two 'b' characters.
>
> There are 2 levels here: the level of the regular expression in which
> you want '\b', and the level of the pattern string in which you need
> '\\b', because strings have their own escape rules which apply first and
> under those '\b' means "backspace character", whereas '\\b' means
> "backslash b".
In addition, \b is not sufficient in most cases as it matches a boundary
between a "word character" and "not-a-word-character". Word characters are
those matched by `\w', which in turn is defined as the equivalent of [0-9A-
Za-z_]. Non-ASCII letters are not included. Even basically English text
can contain non-ASCII characters (borrowed from or written in other
languages):
<http://stackoverflow.com/questions/1015844/how-to-remove-all-characters-
from-a-string/8568325#8568325> f.
Which gives me the idea that a Unicode mode for jsx.regexp.RegExp() to
replace \b, \w and \W – in addition to or using the already implemented
Unicode character properties (\p{Lu} et al.) – would come in handy.
Comments anyone?
PointedEars
--
Sometimes, what you learn is wrong. If those wrong ideas are close to the
root of the knowledge tree you build on a particular subject, pruning the
bad branches can sometimes cause the whole tree to collapse.
-- Mike Duffy in cljs, <news:Xns9FB6521286DB8invalidcom@94.75.214.39>
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
regexp help Andrew Poulos <ap_prog@hotmail.com> - 2012-09-07 14:37 +1000
Re: regexp help Jake Jarvis <pig_in_shoes@yahoo.com> - 2012-09-07 10:55 +0200
Re: regexp help Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-07 15:36 +0200
Re: regexp help Andrew Poulos <ap_prog@hotmail.com> - 2012-09-08 10:27 +1000
Re: regexp help Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-08 09:34 +0200
Re: regexp help "Scott Sauyet" <3103invalid@webnews.fastusenet.org> - 2012-09-11 16:51 +0000
Re: regexp help Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-11 22:31 +0200
Re: regexp help "Scott Sauyet" <3103invalid@webnews.fastusenet.org> - 2012-09-19 11:56 +0000
Re: regexp help Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-19 18:51 +0200
Re: regexp help Scott Sauyet <scott.sauyet@gmail.com> - 2012-09-19 12:52 -0700
Re: regexp help Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-20 02:13 +0200
Re: regexp help Scott Sauyet <scott.sauyet@gmail.com> - 2012-09-20 06:51 -0700
Re: regexp help Dr J R Stockton <reply1237@merlyn.demon.co.uk.invalid> - 2012-09-20 20:23 +0100
Re: regexp help "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-09-11 14:55 -0700
csiph-web