Jump to content

need help with StringRegExp()


E1M1
 Share

Recommended Posts

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

Link to comment
Share on other sites

$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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...