newsgroups-index (beta)

Current group: comp.programming

Help Regular Expression

Help Regular Expression  
thiegau
 Re: Help Regular Expression  
Jens.Toerring at physik.fu-berlin.de
From:thiegau
Subject:Help Regular Expression
Date:22 Jan 2005 03:32:50 -0800
Hello Guys,

Trying to analyse my web site stats, I tried to exclude from the
analysis all the URL that contain fr/ or de/

(Exemple: www.mysite.com/fr/home.php or www.mysite.com/de/home.php).

RegExp are not my favorite topic and I couldn't manage to create a
correct expression to exclude such directories.
Any help would be appreciated!

Thanks folks.

Thiegau
From:Jens.Toerring at physik.fu-berlin.de
Subject:Re: Help Regular Expression
Date:22 Jan 2005 15:10:27 GMT
thiegau wrote:
> Hello Guys,

> Trying to analyse my web site stats, I tried to exclude from the
> analysis all the URL that contain fr/ or de/

> (Exemple: www.mysite.com/fr/home.php or www.mysite.com/de/home.php).

> RegExp are not my favorite topic and I couldn't manage to create a
> correct expression to exclude such directories.

Take only strings that don't match '(^|\/)(de)|(fr)\/', i.e. that
contain neither the string "/de/" or "/fr/" nor that start with "de/"
or "fr/" (since it's not clear if you're talking about URLs only or
if you also mean relative paths). So in PHP (that's what I guess you
are using) you would e.g. loop over an array of URLs (or directories)
with

foreach ( $url as $cur_url ) {
if ( ! preg_match( "(^|\/)(de)|(fr)\/", $cur_url ) )
do_what_ever_you_want_with_the_url( $cur_url );
}
Regards, Jens
--
\ Jens Thoms Toerring ___ Jens.Toerring@physik.fu-berlin.de
\__________________________ http://www.toerring.de
   

Copyright © 2006 newsgroups-index   -   All rights reserved   -   Impressum