Regular expressions come handy when we have this kind of requirement. Regex.Replace method can be used remove the unwanted text
Showing posts with label VB.NET Regex. Show all posts
Showing posts with label VB.NET Regex. Show all posts
Thursday, September 15, 2011
How to Remove Alternate/Extra Text (Text within Parenthesis) using VB.NET/C#
How to Remove Text within Brackets/ Braces using VB.NET/C#
Regular expressions come handy when we have this kind of requirement. Regex.Replace method can be used remove the unwanted text
Regular expressions come handy when we have this kind of requirement. Regex.Replace method can be used remove the unwanted text
private static void RemoveTextWithinParens()
{
string pattern = @"\([^\(\)]+\)";
string interesting_string = "SOMETHING (#2) and some more rhing (#3 inside braces)";
Regex rgx = new Regex(pattern, RegexOptions.IgnoreCase);
MatchCollection matches = rgx.Matches(interesting_string);
string removed_String = rgx.Replace(interesting_string, "");
}
Sunday, June 1, 2008
VB.NET Regular Expression to Check Email Addresses
VB.NET Regular Expression to Validate Email Addresses
Imports System.Text.RegularExpressions
Function IsValid_eMail_Address(ByVal sEmailAdd As String)
Return Regex.IsMatch(sEmailAdd, "[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z_+])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9}$"
End Function
The above will check for email like sales@dotnetdud.com etc and will reject sample@vbadud.c
Or -@vbadud.cm
See Also
Extract Ref Links From WebPage using VB.Net Regular Expressions
Remove HTML Tags from String using .NET Regular Expressions
VB.NET Regular Expression to Check URL
VB.NET Regular Expression to Check Email Addresses
VB.NET Regular Expression to Check MAC Address
Regular Expression to Check Zip Code
Validate eMail Addresses using VB.NET Function
Regular Expressions in Dot Net (.NET)
Subscribe to:
Posts (Atom)