Bokkie Posted March 15, 2006 Share Posted March 15, 2006 Can anyone help me with a regular expression that will validate the GUID below?{1B399A41-C1D0-40A2-9E4F-095868EFAF01}I'd like to be really strict and take the braces and dash characters into account as well as verify the hex groups are comprised of hex characters and don't contain non-hex characters like Z and T for example. I confess I'm hopeless with regular expressions so a free virtual crate of beers to the first contributor. Link to comment Share on other sites More sharing options...
seandisanti Posted March 15, 2006 Share Posted March 15, 2006 Can anyone help me with a regular expression that will validate the GUID below?{1B399A41-C1D0-40A2-9E4F-095868EFAF01}I'd like to be really strict and take the braces and dash characters into account as well as verify the hex groups are comprised of hex characters and don't contain non-hex characters like Z and T for example. I confess I'm hopeless with regular expressions so a free virtual crate of beers to the first contributor. i actually don't use regexp (i am too lazy to try to wrap my head around them) but i can write you up a real quick validator with string functions. Link to comment Share on other sites More sharing options...
greenmachine Posted March 15, 2006 Share Posted March 15, 2006 (edited) I don't normally either, but I can figure out the helpfile well enough to produce this: MsgBox (0, "", StringRegExp ("{1B399A41-C1D0-40A2-9E4F-095868EFAF01}", "(\x{8}\-\x{4}\-\x{4}\-\x{4}\-\x{12})")) It returns 1, which means it passes. Edited March 15, 2006 by greenmachine Link to comment Share on other sites More sharing options...
seandisanti Posted March 15, 2006 Share Posted March 15, 2006 I don't normally either, but I can figure out the helpfile well enough to produce this: MsgBox (0, "", StringRegExp ("{1B399A41-C1D0-40A2-9E4F-095868EFAF01}", "(\x{8}\-\x{4}\-\x{4}\-\x{4}\-\x{12})")) It returns 1, which means it passes.you think you're better than me?! kidding. i won't do better than one line of code with what i'm working on, and it looks like problem is solved. good job man. Link to comment Share on other sites More sharing options...
Joon Posted March 15, 2006 Share Posted March 15, 2006 (edited) I don't normally either, but I can figure out the helpfile well enough to produce this: MsgBox (0, "", StringRegExp ("{1B399A41-C1D0-40A2-9E4F-095868EFAF01}", "(\x{8}\-\x{4}\-\x{4}\-\x{4}\-\x{12})")) It returns 1, which means it passes. Thanks, greenmachine I know little now... so much easier to understand with an example. Edited March 15, 2006 by Joon Link to comment Share on other sites More sharing options...
greenmachine Posted March 16, 2006 Share Posted March 16, 2006 (edited) you think you're better than me?! kidding. i won't do better than one line of code with what i'm working on, and it looks like problem is solved. good job man.Actually I was really surprised that it worked on my first try... most things don't work out that well.Hmm, I just noticed that it doesn't check the brackets... and now that I test more I'm noticing that it doesn't actually return 0 for anything.... time to redo the pattern.Edit - Fixed the pattern: "\{\x{8}-\x{4}-\x{4}-\x{4}-\x{12}\}" Edited March 16, 2006 by greenmachine Link to comment Share on other sites More sharing options...
Valik Posted March 16, 2006 Share Posted March 16, 2006 I wouldn't use regular expressions at all. Strip the {}- characters and then use StringIsXDigit() on it.Func IsValidCLSID($sCLSID) Local $sTemp = StringReplace($sCLSID, "{", "") $sTemp = StringReplace($sTemp, "}", "") $sTemp = StringReplace($sTemp, "-", "") Return StringIsXDigit($sTemp) EndFuncA regular expression would probably be faster, however. Link to comment Share on other sites More sharing options...
Bokkie Posted March 16, 2006 Author Share Posted March 16, 2006 (edited) I don't normally either, but I can figure out the helpfile well enough to produce this: MsgBox (0, "", StringRegExp ("{1B399A41-C1D0-40A2-9E4F-095868EFAF01}", "(\x{8}\-\x{4}\-\x{4}\-\x{4}\-\x{12})")) It returns 1, which means it passes. I've got the latest release installed but my helpfile has nothing in it for StringRegExp. In fact I can't even find it anywhere and SciTE throws a compilation error saying the function could not be found. I can't find it listed in any include files. I've got 3.1.1 installed. Edited March 16, 2006 by Peter Hamilton-Scott Link to comment Share on other sites More sharing options...
nfwu Posted March 16, 2006 Share Posted March 16, 2006 You require the latest BETA release. #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
Bokkie Posted March 16, 2006 Author Share Posted March 16, 2006 (edited) You require the latest BETA release.#)It's a bad day for me. Where do I find the beta download?Edit: I found it... Edited March 16, 2006 by Peter Hamilton-Scott Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 16, 2006 Moderators Share Posted March 16, 2006 http://www.autoitscript.com/forum/index.php?showtopic=19717 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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