myk3 Posted March 13, 2012 Share Posted March 13, 2012 (edited) I am attempting to catch all special characters not available for a computer name ~!@#$%^&*()_=+[]{}{}|;:.'",<>/? this is what i currently have but when i add the extras it breaks $String = StringRegExp ( "abcd!@#efgh", '[~!@#$%^&*()_=+{}|;:.,<>/?]') if $string = "1" then MsgBox(0,"","Error!") endif Edited March 13, 2012 by myk3 Link to comment Share on other sites More sharing options...
DW1 Posted March 13, 2012 Share Posted March 13, 2012 (edited) Hi myk3, I see two issues here, one is that you are not using StringRegExpReplace which is what I think you meant to use. Two is that when you include a "" that is a special character and needs to be "" since "" is the escape character. $String = StringRegExpReplace("abcd~!@#$%^&*()_=+{}|;:.,<>/?fgh", '[~!@#$%^&*()_=+{}|;:.,<>/?]', '') ; add characters you want remove between brackets If $String = "1" Then MsgBox(0, "", "Error!") Else MsgBox(0,'test', $String) EndIf EDIT: If you are going to add "[" and "]" then they will need to have the escape also, "[" "]" Edited March 13, 2012 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
myk3 Posted March 13, 2012 Author Share Posted March 13, 2012 Hi myk3, I see two issues here, one is that you are not using StringRegExpReplace which is what I think you meant to use. Two is that when you include a "" that is a special character and needs to be "" since "" is the escape character. $String = StringRegExpReplace("abcd~!@#$%^&*()_=+{}|;:.,<>/?fgh", '[~!@#$%^&*()_=+{}|;:.,<>/?]', '') ; add characters you want remove between brackets If $String = "1" Then MsgBox(0, "", "Error!") Else MsgBox(0,'test', $String) EndIf EDIT: If you are going to add "[" and "]" then they will need to have the escape also, "[" "]" thanks this worked.. I intend to use StringRegExp since i am not trying to replace anything, just search if it is there or not. Link to comment Share on other sites More sharing options...
myk3 Posted March 13, 2012 Author Share Posted March 13, 2012 Hi myk3, I see two issues here, one is that you are not using StringRegExpReplace which is what I think you meant to use. Two is that when you include a "" that is a special character and needs to be "" since "" is the escape character. $String = StringRegExpReplace("abcd~!@#$%^&*()_=+{}|;:.,<>/?fgh", '[~!@#$%^&*()_=+{}|;:.,<>/?]', '') ; add characters you want remove between brackets If $String = "1" Then MsgBox(0, "", "Error!") Else MsgBox(0,'test', $String) EndIf EDIT: If you are going to add "[" and "]" then they will need to have the escape also, "[" "]" well it almost worked.. It doesnt check for ' or " Link to comment Share on other sites More sharing options...
Mechaflash Posted March 13, 2012 Share Posted March 13, 2012 well it almost worked.. It doesnt check for ' or "Paste what you got. Try escaping those as well as they are being seen as encapsulations. Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
DW1 Posted March 13, 2012 Share Posted March 13, 2012 For the single quote you will have to use the ascii hex code since you wrap the expression in single quotes... this would be x27 = ' '[~!@#$%^&*()][_=+{}|;:.,<>/?x27"]' AutoIt3 Online Help Link to comment Share on other sites More sharing options...
myk3 Posted March 13, 2012 Author Share Posted March 13, 2012 For the single quote you will have to use the ascii hex code since you wrap the expression in single quotes... this would be x27 = ' '[~!@#$%^&*()][_=+{}|;:.,<>/?x27"]' Thanks that worked.. I added x22 for the " also Link to comment Share on other sites More sharing options...
jchd Posted March 13, 2012 Share Posted March 13, 2012 (edited) You can also double the single (or double) quote for that matter. This is the way AutoIt escapes quotes of the same kind which are enclosing the string litteral. Now I'm unsure that you catch all forbidden chars (for computer names) that way. Are you considering NetBios names or DNS names? Edited March 13, 2012 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) 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