Hi,
Can somone please help with a pattern I need to match ...
[# * #] where * means anything and it could occur anywhere and potentially more than once in the string.
So for example say I have a string "This is some text [# Anything #] , in a string, replace [# Anything #] more text." and i want to use 'Replaced' as the replacement string, so I end up with...
"This is some text Replaced , in a string, replace Replaced more text."
And if it was this...
"This is some text [# could be something else #] , in a string, replace [# could be something else #] more text."
you'd get
"This is some text Replaced , in a string, replace Replaced more text."
So the pattern is open square bracket, hash, space, wildcard (*), space, hash, closed square bracket
That is anywhere in a string , 1 or more times.
I have this code...
But am unsure where to start with the pattern syntax, so all help appreciated.
Regards,
1DMF.
"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Dance Music Downloads
Can somone please help with a pattern I need to match ...
[# * #] where * means anything and it could occur anywhere and potentially more than once in the string.
So for example say I have a string "This is some text [# Anything #] , in a string, replace [# Anything #] more text." and i want to use 'Replaced' as the replacement string, so I end up with...
"This is some text Replaced , in a string, replace Replaced more text."
And if it was this...
"This is some text [# could be something else #] , in a string, replace [# could be something else #] more text."
you'd get
"This is some text Replaced , in a string, replace Replaced more text."
So the pattern is open square bracket, hash, space, wildcard (*), space, hash, closed square bracket
That is anywhere in a string , 1 or more times.
I have this code...
Code:
' replace text using regex pattern
Public Function ReplaceText(ByVal sText As String, ByVal sReplacement As String, ByVal sPattern As String) As String
Dim RegEx As RegExp
Set RegEx = New RegExp
With RegEx
.Global = True
.IgnoreCase = True
.Multiline = True
.Pattern = sPattern
End With
ReplaceText = RegEx.Replace(sText, sReplacement)
Set RegEx = Nothing
End Function
But am unsure where to start with the pattern syntax, so all help appreciated.
Regards,
1DMF.
"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Dance Music Downloads