ken82m Posted March 9, 2009 Share Posted March 9, 2009 I suck at this can someone please help me with this. I just want to check the format of something to see if it is a properly formatted IP address. so it should be xxx.xxx.xxx each x has to be a number and each section can be 1-3 numbers Here's my poor attempt lol $1 = "1.1.1.1" $1 = StringRegExp("1.1.1.1", "[:digit:]/x00") MsgBox(0,"is ip", $1) Thanks, Kenny "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains." Link to comment Share on other sites More sharing options...
Authenticity Posted March 9, 2009 Share Posted March 9, 2009 (edited) http://www.regextester.com/Check the list on the bottom, some nice patterns for known decimal inputs like IPv4 etc..Edit: I see it's IPv4 pattern is broken so here it's anyway, fail faster in my opinion:^(?>(?:\d|[01]?\d\d|25[0-5]|2[0-4]\d)\.){3}(?:\d|[01]?\d\d|25[0-5]|2[0-4]\d)$' Edited March 9, 2009 by Authenticity Link to comment Share on other sites More sharing options...
ken82m Posted March 9, 2009 Author Share Posted March 9, 2009 thanks for the string, and the site. Wouldn't happen to know one to help me build one would you? "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains." Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 9, 2009 Moderators Share Posted March 9, 2009 http://www.autoitscript.com/forum/index.ph...c=39932&hl= 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...
GEOSoft Posted March 9, 2009 Share Posted March 9, 2009 Here is another regexp that I think will do what you want. I could be wrong though. That happened once before. "(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})" George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Authenticity Posted March 9, 2009 Share Posted March 9, 2009 It can match for sure, anything from "0.0.0.0somthinglong" to "999.999.999.999Somethingevenlonger...0.0.0.999999999and this" Link to comment Share on other sites More sharing options...
GEOSoft Posted March 9, 2009 Share Posted March 9, 2009 (edited) It can match for sure, anything from "0.0.0.0somthinglong" to "999.999.999.999Somethingevenlonger...0.0.0.999999999and this"That makes twice now (that I've been wrong).Edit. Oooops, forgot to mention that I was talking about twice within a 3 minute time span. Edited March 9, 2009 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Ascend4nt Posted March 10, 2009 Share Posted March 10, 2009 GEOSoft, technically you're correct in looking for 4 1-3-digit pairs, but if you need to make sure it doesn't include any other characters in the string, you can just add the start-of-string and end-of-string characters to each side like this: ^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$ Of course, they are right about invalid IP addresses.. I really don't know the correct range of #'s myself My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
Authenticity Posted March 10, 2009 Share Posted March 10, 2009 You don't need to care if this IP address exists as you may want to make sure it's first in the range 0-255 in all the fields, it's also true that 0.0.0.0 certainly does not exist as 255.255.255.255 for that matter neither. The rest of the check is using a data base or calling ping. Link to comment Share on other sites More sharing options...
GEOSoft Posted March 10, 2009 Share Posted March 10, 2009 It actually could be handled with a stringsplit too. Then just check that the number in each element is between 0 and 255. SmOke_Ns solution works. Just difficult to read with the AutoIt tags and smileys enabled. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 10, 2009 Moderators Share Posted March 10, 2009 (edited) This should work as well, not much different I'm sure from what I've posted before in the link provided:Local $s_text = ClipGet() Local $s_pattern = "((?:(?:[0-1][0-9]{2}|2[0-4][0-9]|25[0-5]|[0-9]){1,2}\.){3}" & _ "(?:[0-1][0-9]{2}|2[0-4][0-9]|25[0-5]|[0-9]))" Local $a_sre = StringRegExp($s_text, $s_pattern, 3) Edited March 10, 2009 by SmOke_N 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