whos_wee_dug
asked on
Regular Expression, detecting certain words
Hi,
I've got a regular expression that checks if sentences such as "A duck is a bird" or "A kitten is a cat" are valid:
^(A)\s\w+\s(is)\s(a)\s\w+$
I'm using vb.net and I want to tell which words are different, i.e I want to pickup from the first sentence "duck" and "bird" and "kitten" and "cat" from the second one. How can I do this?
Cheers,
Col.
I've got a regular expression that checks if sentences such as "A duck is a bird" or "A kitten is a cat" are valid:
^(A)\s\w+\s(is)\s(a)\s\w+$
I'm using vb.net and I want to tell which words are different, i.e I want to pickup from the first sentence "duck" and "bird" and "kitten" and "cat" from the second one. How can I do this?
Cheers,
Col.
^A\s\(w+)\sis\sa\s(\w+)$
ASKER
Also, I tried this but it didn't quite work:
Dim test As String = "A duck is a bird"
Dim re As New Regex("^(A)\s\w+\s(is)\s(a )\s\w+$")
test = re.Replace(test, "$1 $2 $3 $4 $5")
Response.Write("<br/>'" + test + "'")
Dim test As String = "A duck is a bird"
Dim re As New Regex("^(A)\s\w+\s(is)\s(a
test = re.Replace(test, "$1 $2 $3 $4 $5")
Response.Write("<br/>'" + test + "'")
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks once again ozo, you've been a great help.
Cheers,
Col.
Cheers,
Col.