Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In your Regex.Matches, you need to use \b word boundaries character. I just wrote an example code in C#, and now I noticed that your question is for VB.NET, so I'll add both code examples:</p> <p><strong>C#:</strong></p> <pre><code> //Example 1: var testString = "parfaite ment aux exigences create évolutives du marché d aujourd hui"; var pattern = "ate"; MatchCollection found = Regex.Matches(testString, @"\b" + pattern + @"\b"); if (found.Count &gt; 0) { foreach (Match f in found) { Console.WriteLine("'{0}' found at position {1} in given testString.", f.Value, f.Index); } } else Console.WriteLine("No matches in given testString."); //Example 2: var testString1 = "parfaite ment aux exigences cre*ate* évolutives du marché d aujourd hui I don't know the language but this: ate and the last one should be found: ate!"; var pattern1 = "ate"; MatchCollection found1 = Regex.Matches(testString1, @"\b" + pattern1 + @"\b"); if (found1.Count &gt; 0) { foreach (Match f in found1) { Console.WriteLine("'{0}' found at position {1} in given testString1.", f.Value, f.Index); } } else Console.WriteLine("No matches in given testString1."); Console.ReadLine(); </code></pre> <p><strong>VB.NET:</strong></p> <pre><code> 'Example 1: Dim testString = "parfaite ment aux exigences create évolutives du marché d aujourd hui" Dim pattern = "ate" Dim found As MatchCollection = Regex.Matches(testString, "\b" &amp; pattern &amp; "\b") If found.Count &gt; 0 Then For Each f In found Console.WriteLine("'{0}' found at position {1} in given testString.", f.Value, f.Index) Next Else Console.WriteLine("No matches in given testString.") End If 'Example 2: Dim testString1 = "parfaite ment aux exigences cre*ate* évolutives du marché d aujourd hui I don't know the language but this: ate and the last one should be found: ate!" Dim pattern1 = "ate" Dim found1 As MatchCollection = Regex.Matches(testString1, "\b" &amp; pattern1 &amp; "\b") If (found1.Count &gt; 0) Then For Each f As Match In found1 Console.WriteLine("'{0}' found at position {1} in given testString1.", f.Value, f.Index) Next Else Console.WriteLine("No matches in given testString1.") End If Console.ReadLine() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload