I don't have access to c#, but here it is in VB6. Should be easy enough to convert?
Dim oRE As New RegExp
Dim oMatch As Match
Dim oMatches As MatchCollection
Dim oSubMatches As SubMatches
Dim s As String
s = "some text <callMethod=24,7> some more text <callMethod=13,6> and some more text"
With oRE
'Need to search for all occurences
.Global = True
.MultiLine = True
.Pattern = "<callMethod=(\d*),(\d*)>"
Set oMatches = .Execute(s)
'Don't want to replace all occurences at once
.Global = False
End With
For Each oMatch In oMatches
Set oSubMatches = oMatch.SubMatches
s = oRE.Replace(s, CallMethod(oSubMatches(0),
Next oMatch
Debug.Print s
Public Function CallMethod(i1 As Integer, i2 As Integer) As String
CallMethod = "Return string " & i1 & " and " & i2
End Function
Gives the following result.
"some text Return string 24 and 7 some more text Return string 13 and 6 and some more text"
Sorry if this MUST be in c#. Let me know and I'll see if I can't help convert it.
John
Main Topics
Browse All Topics





by: prasitleePosted on 2004-05-21 at 08:49:41ID: 11127837
Hi Smoerble,
Can you give me the exact details of what you want again ? I am not sure if I understand correctly or not.
Meng