Note that there are some explanatory texts on larger screens.

plurals
  1. PORegex Pattern Matching
    primarykey
    data
    text
    <p>I am developing a regex/pattern tester in vb.net where I have three textbox's:</p> <ul> <li>Textbox1: Here I enter my regular expression for pattern matching in textbox2</li> <li>Textbox2: Upload the plain-texts from dB and then look for a match</li> <li>Textbox3: Displays the result of the search. </li> </ul> <p>Now the issue I am having is when I enter a regular expression in <strong>Textbox1</strong> and click search it is unable to find any matching pattern even though I have made sure a matching text is present in the paragraph.</p> <p>But whereas, if I enter the non-regex word/text itself in Textbox1 it is able to find a match.</p> <p>In my button click_event I have initiated all the relavent regex functions etc but still not able to figure out why it wont except regex expressions instead of the word itself.</p> <p>Here is the code I am using for pattern search:</p> <pre><code>Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim m As Match Dim re As Regex Dim matches As MatchCollection 'Clear result area tbResults.Text = "" Try re = New Regex(tbPattern.Text) Catch ex As Exception MsgBox("invalid regular expression") Exit Sub End Try If cbIgnoreCase.Checked And cbMultiline.Checked And cbSingleLine.Checked Then re = New Regex(tbPattern.Text, RegexOptions.IgnoreCase And RegexOptions.Multiline And RegexOptions.Singleline) ElseIf cbIgnoreCase.Checked And cbMultiline.Checked And (Not cbSingleLine.Checked) Then re = New Regex(tbPattern.Text, RegexOptions.IgnoreCase And RegexOptions.Multiline) ElseIf cbIgnoreCase.Checked And (Not cbMultiline.Checked) And cbSingleLine.Checked Then re = New Regex(tbPattern.Text, RegexOptions.IgnoreCase And RegexOptions.Multiline) ElseIf (Not cbIgnoreCase.Checked) And cbMultiline.Checked And cbSingleLine.Checked Then re = New Regex(tbPattern.Text, RegexOptions.Multiline And RegexOptions.Singleline) ElseIf cbIgnoreCase.Checked Then re = New Regex(tbPattern.Text, RegexOptions.IgnoreCase) ElseIf cbMultiline.Checked Then re = New Regex(tbPattern.Text, RegexOptions.Multiline) ElseIf cbSingleLine.Checked Then re = New Regex(tbPattern.Text, RegexOptions.Singleline) Else re = New Regex(tbPattern.Text) End If 'get matches matches = re.Matches(tbPgCon.Text) 'display matches found tbResults.Text = "Count : " &amp; matches.Count For Each m In matches tbResults.Text = tbResults.Text &amp; vbCrLf &amp; "----" &amp; vbCrLf &amp; m.Value Next Cursor.Current = Cursors.Default End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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. 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