Ok, I have a problem using Regular Expressions in VB.NET 2005:
Imports System
Imports System.Text
Imports System.Text.RegularExpressions
'Define regex
Dim regExp As Regex
'Italic text
regExp = New Regex("$1")
RichTextBox2.Text = regExp.Replace(RichTextBox1.Text, "\[i\](.+?)\[\/i\]")
From my point of view, this code should change blahblah from richtextbox1 into [i]blahblah[/i] in richtextbox2.
But, when I Debug this app, it just copy (or anything I type in) into richtextbox2. No change. Someone can see where is my problem ?
Loading
FroglegPosted Apr 8, 2011, 2:15 PM
Suthish NairPosted Apr 8, 2011, 10:47 AM
Karthikeyan AnbarasanPosted Apr 8, 2011, 2:48 AM
FroglegPosted Mar 25, 2011, 5:24 PM
Private Sub bttnReplace_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnReplace.Click
Dim toBeReplaceChar() As String = {"<", ">"}
Dim replaceChar() As String = {"[", "]"}
TextBox2.Text = replaceString(TextBox1.Text, toBeReplaceChar, replaceChar)
End Sub
Public Function replaceString(ByVal str As String, ByVal beRep() As String, ByVal rep() As String)
Dim answer As String
Dim count As Integer
For Each cr As String In beRep
answer = str.Replace(cr, rep(count))
str = answer
count += 1
Next
Return answer
End Function