I want to find in string some letters and returns the (full word) which contains of this letters and the letters may be in the mid of the word ( or at the first or end of the word some thing like this
Dim match As Match = Regex.Match(string, "From\s+([A-Za-z0-9\-_]+)\s*", RegexOptions.IgnoreCase)
If (match.Success) Then
matchedWord = match.Groups(1).Value
End If
Simply use the regex expression
\w*find\w*
\w*
stands for any number of word characters. The *
quantifier is greedy and extends find
(the letters we want to find) with a prefix and a suffix of word characters ( \w
) up to the boundaries of the word.
We don't need groups. match.Value
is the whole word containing find
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.