VB Regex.Replace with repeating brackets
I am trying to search in a string for a certain value and replace it with
another.
The example: String: "/accounts/{accountId}/cheques/{chequeId}/cancel" I
am trying to replace anything between { and } with the number 1. So I
would end up with: String: "/accounts/1/cheques/1/cancel"
I am using the following:
prepedURI = System.Text.RegularExpressions.Regex.Replace(prepedURI,
"{.*}", "1")
But unfortunately, the Replace function is returning: String:
"/accounts/1/cancel"
It seems to be ignoring the first } and replacing everything up to the 2nd }.
Any advice? Excuse my dumb. This is my first Regex experience, and I am
trying my best to understand all these 'flags' in the pattern.
Example (you can paste into a button click event to see what I mean):
Dim prepedURI As String = "/accounts/{accountId}/cheques/{chequeId}/cancel"
prepedURI = System.Text.RegularExpressions.Regex.Replace(prepedURI,
"{.*}", "1")
MsgBox(prepedURI)
No comments:
Post a Comment