Sign in to follow this  
Followers 0
E1M1

need help with StringRegExp()

3 posts in this topic

#1 ·  Posted (edited)

I want to see if file extension is .doc or .xls but for some reason it returns always 1. I have file.dox so it should return 0 but it don't.

MsgBox(0,0,StringRegExp ( "file.dox", "[.doc.xls]" ,0 ))

i also tried

MsgBox(0,0,StringRegExp ( "file.dox", "[*.doc*.xls]" ,0 ))

but it didn't work either

Edited by E1M1

edited

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

$1 = "file.doc"  ; True
$2 = "file.xls"  ; True
$3 = "file.docx" ; False

; (?i) = case insensitive, \z = end of string, (?:doc|xls) = match 'doc' OR 'xls', 
; \. = match '.', \ = escape character to match special characters literally, like ., [, ( etc.

; So what this says is: 'Match anything that ends with either .DOC, .doc, .XLS or .xls'.
$regEx = "(?i)\.(?:doc|xls)\z"

MsgBox(0, "", StringRegExp($1, $regEx))
MsgBox(0, "", StringRegExp($2, $regEx))
MsgBox(0, "", StringRegExp($3, $regEx))

Edited by d4ni

Share this post


Link to post
Share on other sites

nice, great thanks!


edited

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0