E1M1 Posted February 27, 2010 Share Posted February 27, 2010 (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 February 27, 2010 by E1M1 edited Link to comment Share on other sites More sharing options...
dani Posted February 27, 2010 Share Posted February 27, 2010 (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 February 27, 2010 by d4ni Link to comment Share on other sites More sharing options...
E1M1 Posted February 27, 2010 Author Share Posted February 27, 2010 nice, great thanks! edited Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now