Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help Regular Expressions

Status
Not open for further replies.

thieg

IS-IT--Management
Jul 1, 2002
5
0
0
US
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: or
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
 
thieg,

Maybe this will be enough?
Code:
spattern="/fr/|/de/"	'negative test can use "^/fr/|^/de/"
aurl=array("[URL unfurl="true"]http://www.mysite.com/fr/home.php",[/URL] _
    "[URL unfurl="true"]http://www.mysite.com/de/home.php",[/URL] _
    "[URL unfurl="true"]http://www.mysite.com/uk/home.php")[/URL]
for each surl in aurl
    if not re_match(spattern,surl) then
        wscript.echo "Accepted : " & surl
    else
        wscript.echo "Refused : " & surl
    end if
next

function re_match(pttrn, s)
    set re=New RegExp
    re.pattern=pttrn
    re.ignorecase=true
    re.global=true
    set matches = re.execute(s)
    if matches.count<>0 then
        re_match=true
    else
        re_match=false
    end if
end function
regards - tsuji
 
You may also simply play with the InStr function:
If InStr(1,someURL,"/fr/",1)+InStr(1,someURL,"/de/",1)=0 Then
MsgBox someURL & " accepted"
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Amendment:
Nothing changed, just cross out silly side-note in the script during testing.
[tt]
spattern="/fr/|/de/" [COLOR=white white]'negative test can use "^/fr/|^/de/"[/color]
[/tt]
- tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top