|
From: Mutley on 28 Jun 2008 05:37 Dear All, I have the following regular expression to check that a subnet has been entereted correctly during a server prep script that I am writing. It works fine if a number other than 0 is entered as the last octet however if i enter more than one zero it accepts it as a valid subnet. i want it to check that only one 0 has been entered as the last octet. And ideas on the syntax. and if anyone can reccommend a couple of tutorial websites for regular expressions and tutorials that would be great. Pardon the terrible explanation. strRegEx = "\d{1,3}\.\d{1,3}\.\d{1,3}\.0" Cheers, -- Ben
From: Steve on 28 Jun 2008 06:17 Mutley wrote: > > I have the following regular expression to check that a subnet has > been entereted correctly during a server prep script that I am > writing. It works fine if a number other than 0 is entered as the > last octet however if i enter more than one zero it accepts it as a > valid subnet. i want it to check that only one 0 has been entered as > the last octet. > > strRegEx = "\d{1,3}\.\d{1,3}\.\d{1,3}\.0" Regular expressions find patterns anywhere in a string. To anchor the pattern to the whole string, use "^" at the start and "$" at the end (and make sure the regexp's multiline property is false). strRegEx = "^\d{1,3}\.\d{1,3}\.\d{1,3}\.0$" > and if anyone can > reccommend a couple of tutorial websites for regular expressions and > tutorials that would be great. http://www.google.com/search?q=regex+tutorial Introduction to Regular Expressions: http://msdn.microsoft.com/en-us/library/6wzad2b2(VS.85).aspx Regular Expression (RegExp) Object http://msdn.microsoft.com/en-us/library/yab2dx62(VS.85).aspx -- Steve When we are unable to find tranquility within ourselves, it is useless to seek it elsewhere. -Francois de La Rochefoucauld
From: Mutley on 28 Jun 2008 06:36 worked a treat thanks a million "Steve" <cerberus40(a)geemail.com> wrote in message news:ubhgJhQ2IHA.1240(a)TK2MSFTNGP02.phx.gbl... > Mutley wrote: >> >> I have the following regular expression to check that a subnet has >> been entereted correctly during a server prep script that I am >> writing. It works fine if a number other than 0 is entered as the >> last octet however if i enter more than one zero it accepts it as a >> valid subnet. i want it to check that only one 0 has been entered as >> the last octet. >> >> strRegEx = "\d{1,3}\.\d{1,3}\.\d{1,3}\.0" > > Regular expressions find patterns anywhere in a string. To anchor the > pattern to the whole string, use "^" at the start and "$" at the end (and > make sure the regexp's multiline property is false). > > strRegEx = "^\d{1,3}\.\d{1,3}\.\d{1,3}\.0$" > >> and if anyone can >> reccommend a couple of tutorial websites for regular expressions and >> tutorials that would be great. > > http://www.google.com/search?q=regex+tutorial > > Introduction to Regular Expressions: > http://msdn.microsoft.com/en-us/library/6wzad2b2(VS.85).aspx > > Regular Expression (RegExp) Object > http://msdn.microsoft.com/en-us/library/yab2dx62(VS.85).aspx > > -- > Steve > > When we are unable to find tranquility within ourselves, it is useless > to seek it elsewhere. -Francois de La Rochefoucauld >
From: David Trimboli on 30 Jun 2008 09:39 Mutley wrote: > and if anyone can reccommend a couple of tutorial websites for > regular expressions and tutorials that would be great. Perhaps the best online tutorial for learning about regular expressions: http://www.regular-expressions.info/ -- David Stardate 8497.1
|
Pages: 1 Prev: How can I manipulate Sharepoint Lists in VBScript? Next: substitute for subst |