Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.42!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="ISO-8859-1" Message-ID: <1326734.ds2RrIXCgJ@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Fri, 28 Oct 2011 04:12:06 +0200 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 7Bit Subject: Re: Regular expression question Newsgroups: comp.lang.javascript References: Followup-To: comp.lang.javascript MIME-Version: 1.0 Lines: 29 NNTP-Posting-Date: 28 Oct 2011 04:12:07 CEST NNTP-Posting-Host: 67a8b4f5.newsspool3.arcor-online.net X-Trace: DXC=7`=hUD0QNScg`45cDR8l?oMcF=Q^Z^V3h4Fo<]lROoRa8kF posted: >> First thing, I'm a regular expression newbie.... somewhat anyways... >> I would like to recognize the difference between this url: >> http://quaaoutlodge.com/site/the-lodge/our-history.html >> and that url: >> http://quaaoutlodge.com/site/the-lodge.html >> and at the same time extract the document name (our-history or the- >> lodge) and the directory name if present (the-lodge). >> I got stuck at how rto rcognize the second directory instead of the >> first (the-lodge/ instead of site/) with "\b\/[a-z]+\/" how do i get >> the second one only? > > The easiest way, teaching nothing about RegExps, should be to use the > string method 'split' with an argument "/", and contemplate the result > and its length. By contrast, that requires accessing the `length' property of the resulting array, too, and is inflexible with regard to potential query and fragment parts. PointedEars -- var bugRiddenCrashPronePieceOfJunk = ( navigator.userAgent.indexOf('MSIE 5') != -1 && navigator.userAgent.indexOf('Mac') != -1 ) // Plone, register_function.js:16