using expressions

Winston

Junior Contributor
Joined
Jan 25, 2003
Messages
266
Location
Sydney, Australia
can someone teach me how to use expressions

and also if u can could u help me make one that validates a string is the form of http:// as the beginning and the rest can be anything
 
Regular expressions are not used to find exact words, although they can be, they are just too complicated for that. They are used to find patterns in the text and they are not very easy to use.

I suggest looking this topic up on the net unless you have a specific question about an expression.

Although I did make an expression that found an exact string...I don't know what I was thinking.
C#:
/// <summary>
/// Matches all occurances of an exact word.  Each match is located in a group called G.
/// </summary>
public static MatchCollection FindExact(ref string text, string find)
{
   MatchCollection mc = Regex.Matches(text, @"\W" + "(?<G>" + find + ")" + @"\W");
   return mc;
}
You or I could replicate this with a loop to find all exact matches of a word.
 
Last edited:
Winston said:
can could u help me make one that validates a string is the form of http:// as the beginning and the rest can be anything

Visual Basic:
If YourStringVar.StartsWith("http://") Then
'-YourStringVar is OK...
End If
 
Back
Top