Hello.
Is there any method to validate if string contains valid IP address?
I also need the method to valideta email address in string.
Thank you. 5 7814
you need to use regular expressions.
i.e. to validate a uk post code example
string postCodeRegEx =
@"(^((([A-PR-UWYZ])([0-9][0-9A-HJKS-UW]?))|(([A-PR-UWYZ][A-HK-Y])([0-9][0-9ABEHMNPRV-Y]?))\s{0,2}(([0-9])([ABD-HJLNP-UW-Z])([ABD-HJLNP-UW-Z])))|(((GI)(R))\ s{0,2}((0)(A)(A )))$)|(^
*$)";
if (System.Text.Re gularExpression s.Regex.IsMatch ("W1A 1BC",postCodeRe gEx) ==
false) {
MessageBox.Show ("Not a valid post code");
}
Regular expressions look fairly daunting, but like a complex SQL query, if
you do it in parts, they're fairly straight forward.
You need to know about www.regexlib.com also, otherwise you'll spend ages
reinventing the wheel. Here you can find literally 1,000s of reg
expressions people have already written.
There are also tools for testing them, etc.
HTH
Sam
"Dave" <da*********@ho tmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. .. Hello.
Is there any method to validate if string contains valid IP address? I also need the method to valideta email address in string.
Thank you.
Hi Dave,
You can use regular expressions. Here's how: http://msdn.microsoft.com/library/de...xpressions.asp
And here's a site you can search for regular expressions without having to
create all of them yourself: http://regexlib.com/
Joe
-- http://www.csharp-station.com
"Dave" <da*********@ho tmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. .. Hello.
Is there any method to validate if string contains valid IP address? I also need the method to valideta email address in string.
Thank you.
Oh! it's too dificalt for me can you show me it for IP validating please?
"Sam Martin" <sa*********@ya hoo.co.uk> wrote in message
news:uu******** ******@TK2MSFTN GP09.phx.gbl... you need to use regular expressions.
i.e. to validate a uk post code example
string postCodeRegEx = @"(^((([A-PR-UWYZ])([0-9][0-9A-HJKS-UW]?))|(([A-PR-UWYZ][A-HK-Y])([0-9][0-9ABEHMNPRV-Y]?))\s{0,2}(([0-9])([ABD-HJLNP-UW-Z])([ABD-HJLNP-UW-Z])))|(((GI)(R))\ s{0,2}((0)(A)(A )))$)|(^ *$)";
if (System.Text.Re gularExpression s.Regex.IsMatch ("W1A 1BC",postCodeRe gEx) == false) { MessageBox.Show ("Not a valid post code"); }
Regular expressions look fairly daunting, but like a complex SQL query, if you do it in parts, they're fairly straight forward.
You need to know about www.regexlib.com also, otherwise you'll spend ages reinventing the wheel. Here you can find literally 1,000s of reg expressions people have already written. There are also tools for testing them, etc.
HTH Sam
"Dave" <da*********@ho tmail.com> wrote in message news:%2******** ********@TK2MSF TNGP10.phx.gbl. .. Hello.
Is there any method to validate if string contains valid IP address? I also need the method to valideta email address in string.
Thank you.
you're having a laugh right, all you had to do was get another regular
expression from the site listed in both responses to your post
one Reg ex i got from that very site after search for "IP" was
@"\b(([01]?\d?\d|2[0-4]\d|25[0-5])\.){3}([01]?\d?\d|2[0-4]\d|25[0-5])\b"(try
it, http://www.regexlib.com/Search.aspx >> "IP" >> Search)
If you send me you prject specification, i'll code it all for you
HTH
Sam
(ps, im only joking)
"Dave" <da*********@ho tmail.com> wrote in message
news:Od******** ******@TK2MSFTN GP15.phx.gbl... Oh! it's too dificalt for me can you show me it for IP validating please?
"Sam Martin" <sa*********@ya hoo.co.uk> wrote in message news:uu******** ******@TK2MSFTN GP09.phx.gbl... you need to use regular expressions.
i.e. to validate a uk post code example
string postCodeRegEx = @"(^((([A-PR-UWYZ])([0-9][0-9A-HJKS-UW]?))|(([A-PR-UWYZ][A-HK-Y])([0-9][0-9ABEHMNPRV-Y]?))\s{0,2}(([0-9])([ABD-HJLNP-UW-Z])([ABD-HJLNP-UW-Z])))|(((GI)(R))\ s{0,2}((0)(A)(A )))$)|(^ *$)";
if (System.Text.Re gularExpression s.Regex.IsMatch ("W1A 1BC",postCodeRe gEx) == false) { MessageBox.Show ("Not a valid post code"); }
Regular expressions look fairly daunting, but like a complex SQL query, if you do it in parts, they're fairly straight forward.
You need to know about www.regexlib.com also, otherwise you'll spend ages reinventing the wheel. Here you can find literally 1,000s of reg expressions people have already written. There are also tools for testing them, etc.
HTH Sam
"Dave" <da*********@ho tmail.com> wrote in message news:%2******** ********@TK2MSF TNGP10.phx.gbl. .. Hello.
Is there any method to validate if string contains valid IP address? I also need the method to valideta email address in string.
Thank you.
Dave,
To validate an IP address, use the static Parse method on the IPAddress
class in the System.Net namespace.
To validate the email address in a string, I would use the Uri class,
adding "mailto:" before the address, and trying to create a Uri instance
from that. If it throws an exception, then you know it is not valid.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Dave" <da*********@ho tmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. .. Hello.
Is there any method to validate if string contains valid IP address? I also need the method to valideta email address in string.
Thank you. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: SHC |
last post by:
Hi all,
I have a VC++ .NET 2003 - Windows XP Pro PC. I created a Win32 console
application in my VC++ .NET 2003 and copied validateDOM.cpp, books.xml and
books.xsd (see the attached files below) from Microfost MSDN Library for my
project "validateXML". When I did "Build" on my project, I got the following
fatal error C1010:
c:\Documents and Settings\SHC\My Documents\Visual Studio
Projects\valoidateDOM\valoidateDOM.cpp(273): fatal error...
|
by: Jim Heavey |
last post by:
When should you use the Page.Validate() method? I thought you would use this method if you have some Server side validation (CustomControl's) you wanted to use and this would cause them to be invoked. I am probably wrong about that.
If I am suppose to use this function, the edits seemed to be invoked even when you have pressed the cancel and the "CausesValidation" is set to false. Is there a way to get around this (might just be an...
|
by: jjbutera |
last post by:
I know how to use the ErrorProvider in my winforms..or do I? I validate
the values and set the ErrorProvider in the validating event. If not
valid, I set e.Cancel = True. I clear the ErrorProvider in the
validated event.
Is there a way to know if all validated controls pass validation when
the user clicks an OK button? In ASP.Net there's the Page.IsValid
method. Is there something similar in winforms, or do I still have to
write an...
|
by: Marc Scheuner |
last post by:
Folks,
I'm faced with a dilemma here - I have an XML document and for part of it, I
have an XSD schema to validate it - but not for the rest of it.
Can I still validate at least part of the XML document?
I was hoping to use the XmlDocument.Validate(ValidationEventHandler,
XmlNode) method for that - doesn't seem to work...
|
by: Brybot |
last post by:
I have a form that i've split up into multiple asp:panels, each panel
has a number of validators which work correctly.
At on the last panel, i want to commit the data collected to a
database. I figured since all the panel data is still being sent
through the postbacks, instead of using Sessions, or HttpContext, I
could just take the values from the textboxes.
This all works fine, except for security. I realized that I could
inject...
| |
by: Mike Hofer |
last post by:
Please forgive the cross-post to multiple forums. I did it
intentionally, but I *think* it was appropriate given the nature of my
question.
I'm working on an open source code library to help automate and clean
up parameter validation code. It's almost ready to go into open beta.
But one last little glitch is holding me up, and that would be the
name of the factory class that serves as the entry point into the
library: Validate.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |