Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #40876
| From | JJ <jj4public@gmx.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: trying to match a "word", having difficulty with a "Lookbehind assertion" |
| Date | 2022-05-21 19:13 +0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <d4isn07io5cf.h6kqtics0wrc.dlg@40tude.net> (permalink) |
| References | <t6aath$15hc$1@gioia.aioe.org> |
On Sat, 21 May 2022 11:20:22 +0200, R.Wieser wrote:
> Hello all,
>
> I'm trying to match group of characters, delimited by anything that does not
> belong in that group.
>
> Case in point: "Couldn't understand a g**d*** word she was saying!"
>
> I would like to match the "g**d***" sequence of letters.
>
> For that I've tried to use a RegEx :
>
> RegExp("(?<=[^a-zA-Z\*])"+escapeRegExp(find)+"(?=[^a-zA-Z\*])",'gi')
>
> -or-
>
> RegExp("(?<![a-zA-Z\*])"+escapeRegExp(find)+"(?=[^a-zA-Z\*])",'gi')
>
> ("escapeRegExp()" escapes the "*" to "\*")
>
> The problem is that neither of the above seem to match anything.
>
> When I use the following
>
> RegExp("\ \b"+escapeRegExp(find)+"(?=[^a-zA-Z\*])",'gi')
>
> (no space between the first two slashes. Had to insert it otherwise my
> newsclient turns it into a link)
>
> all goes well - but for the problem that than the partial "d***" is matched
> before "g**d***", throwing everything off.
>
> Question: if not the above, what /am/ I suppose to use as the "look behind
> assertion" ?
>
> Regards,
> Rudy Wieser
Look-behind is used to match patternA which follows or not follows patternB,
and does not include patternB in the match result.
Your condition is to simply to match "g**d***". You do not have a condition
that, "g**d***" must follow or must not follow other pattern. So,
Look-behind is not needed, or perhaps, not applicable.
For matching just "g**d***" as a whole word, we could just use:
(note: `*` is substituted with `#`)
/\bg##d###\b/gi
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
trying to match a "word", having difficulty with a "Lookbehind assertion" "R.Wieser" <address@not.available> - 2022-05-21 11:20 +0200
Re: trying to match a "word", having difficulty with a "Lookbehind assertion" The Natural Philosopher <tnp@invalid.invalid> - 2022-05-21 11:17 +0100
Re: trying to match a "word", having difficulty with a "Lookbehind assertion" "R.Wieser" <address@not.available> - 2022-05-22 13:42 +0200
Re: trying to match a "word", having difficulty with a "Lookbehind assertion" The Natural Philosopher <tnp@invalid.invalid> - 2022-05-22 13:03 +0100
Re: trying to match a "word", having difficulty with a "Lookbehind assertion" "R.Wieser" <address@not.available> - 2022-05-22 17:42 +0200
Re: trying to match a "word", having difficulty with a "Lookbehind assertion" The Natural Philosopher <tnp@invalid.invalid> - 2022-05-23 13:57 +0100
Re: trying to match a "word", having difficulty with a "Lookbehind assertion" JJ <jj4public@gmx.com> - 2022-05-21 19:13 +0700
Re: trying to match a "word", having difficulty with a "Lookbehind assertion" "R.Wieser" <address@not.available> - 2022-05-21 16:33 +0200
Re: trying to match a "word", having difficulty with a "Lookbehind assertion" "R.Wieser" <address@not.available> - 2022-05-21 19:45 +0200
Re: trying to match a "word", having difficulty with a "Lookbehind assertion" Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2022-06-09 00:14 +0200
Re: trying to match a "word", having difficulty with a "Lookbehind assertion" "R.Wieser" <address@not.available> - 2022-06-09 09:16 +0200
Re: trying to match a "word", having difficulty with a "Lookbehind assertion" Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2022-06-09 12:21 +0200
Re: trying to match a "word", having difficulty with a "Lookbehind assertion" Scott Sauyet <scott@sauyet.com> - 2022-06-14 10:56 -0700
Re: trying to match a "word", having difficulty with a "Lookbehind assertion" "R.Wieser" <address@not.available> - 2022-06-15 09:47 +0200
Re: trying to match a "word", having difficulty with a "Lookbehind assertion" Scott Sauyet <scott@sauyet.com> - 2022-06-15 12:42 -0700
Re: trying to match a "word", having difficulty with a "Lookbehind assertion" "R.Wieser" <address@not.available> - 2022-06-15 22:15 +0200
Re: trying to match a "word", having difficulty with a "Lookbehind assertion" Scott Sauyet <scott@sauyet.com> - 2022-06-15 13:32 -0700
Re: trying to match a "word", having difficulty with a "Lookbehind assertion" "R.Wieser" <address@not.available> - 2022-06-16 09:16 +0200
Re: trying to match a "word", having difficulty with a "Lookbehind assertion" Scott Sauyet <scott@sauyet.com> - 2022-06-16 10:33 -0700
Re: trying to match a "word", having difficulty with a "Lookbehind assertion" "R.Wieser" <address@not.available> - 2022-06-16 21:18 +0200
Re: trying to match a "word", having difficulty with a "Lookbehind assertion" Scott Sauyet <scott@sauyet.com> - 2022-06-17 09:56 -0700
Re: trying to match a "word", having difficulty with a "Lookbehind assertion" Кристьян Робам <ingel1983912@gmail.com> - 2022-06-16 23:34 -0700
Re: trying to match a "word", having difficulty with a "Lookbehind assertion" Härra Rabmo <ingel1983912@gmail.com> - 2022-07-06 09:13 -0700
csiph-web