Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #20581

Re: Regexp confusion

Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail
Content-Type text/plain; charset="UTF-8"
Message-ID <9161127.hJ6kbhveRM@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Reply-To Thomas 'PointedEars' Lahn <usenet@PointedEars.de>
Organization PointedEars Software (PES)
Date Sun, 07 Jul 2013 22:18:30 +0200
User-Agent KNode/4.10.4
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 confusion
Newsgroups comp.lang.javascript
References <sh5vv3omcuc2$.1ls4uvq7bzu5d$.dlg@40tude.net> <c1df98f5-f298-4131-b7a9-fd6c054b92bf@googlegroups.com>
MIME-Version 1.0
Lines 63
NNTP-Posting-Date 07 Jul 2013 22:18:32 CEST
NNTP-Posting-Host 1cba3a7d.newsspool4.arcor-online.net
X-Trace DXC=j@:9m>CR6]:RLigj];iP=84IUK<Cl32<14Fo<]lROoR18kF<OcfhCO;9aNUc68?K]8DZm8W4\YJN<b@mF9jNikd5W@XamafOF];F3d]=V@<m_>
X-Complaints-To usenet-abuse@arcor.de
Xref csiph.com comp.lang.javascript:20581

Show key headers only | View raw


dann90038@gmail.com wrote:

> To JJ

<http://www.netmeister.org/news/learn2quote.html>
<http://jibbering.com/faq/#posting>
<http://PointedEars.de/faq#posting>

> it works for me in js if I use
> \.feed(burner|sportal)\.com\/|feed.*\.gif($|\?)*

Which is nonsense.  Neither can the end of input/line be repeated, nor is 
the “?” allowed to be repeated (unescaped) in a “http(s):”-URI-Reference.
 
> and I get matches on all 3 with the string
> http://feeds.feedburner.com/any
> http://feed.thesite.com/any/blah.gif
> http://feedsite.com/any/blah.gif?var=blah

And you also get a match for

  http://feedsite.com/any/blah.gif??????????var=blah

which certainly is _not_ a valid “http(s):”-URI-Reference.
 
> it also works with
> \.feed(burner|sportal)\.com\/|feed.*\.gif($|\?)
> if my string alone is
> http://feed.thesite.com/any/blah.gif
> 
> so, I'd think there's something after the ".gif" which isn't $ end of
> input or "?" character

RFC 3986, Appendix B, contains a *proper* regular expression for matching 
URIs that can be adapted to result in

  /\.feed(burner|sportal)\.com\/|feed[^?]*\.gif(\?[^#]*)?(#.*)?$/

or (non-greedy matching, probably not worth the incompatiblity here)

  /\.feed(burner|sportal)\.com\/|feed[^?]*\.gif(\?.*?)?(#.+)?$/

It is possible that this is still not what the OP needs as then there can 
only be query-part and fragment-part if a resource name was specified (“/a|
b(c?)/” ≡ “/(?:a)|(?:b(c?))/”).  A more viable solution might be

  /(\.feed(burner|sportal)\.com\/|feed[^?]*\.gif)(\?[^#]*)?(#.*)?$/
   ^                                            ^
or

  /(\.feed(burner|sportal)\.com\/|feed[^?]*\.gif)(\?.*?)?(#.+)?$/
   ^                                            ^
Note the extra parentheses that group the outer alternation.  Also, where 
non-greedy matching is supported, potentially more efficient non-capturing 
parentheses are supported, for example:

  /(?:\.feed(?:burner|sportal)\.com\/|feed[^?]*\.gif)(\?.*?)?(#.+)?$/

-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Regexp confusion JJ <duh@nah.meh> - 2013-07-08 00:26 +0700
  Re: Regexp confusion dann90038@gmail.com - 2013-07-07 12:21 -0700
    Re: Regexp confusion Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-07-07 22:18 +0200
  Re: Regexp confusion Denis McMahon <denismfmcmahon@gmail.com> - 2013-07-07 20:28 +0000
  Re: Regexp confusion JJ <duh@nah.meh> - 2013-07-08 08:24 +0700
    Re: Regexp confusion Andreas Bergmaier <andber93@web.de> - 2013-07-08 17:51 +0200
      Re: Regexp confusion JJ <duh@nah.meh> - 2013-07-09 03:58 +0700

csiph-web