What do you mean with the start and end strings?
The UDF works fine with no problem at all ..
Replace more characters using UDF
-
- PlatinumLounger
- Posts: 4931
- Joined: 31 Aug 2016, 09:02
-
- 5StarLounger
- Posts: 964
- Joined: 08 Nov 2012, 17:54
Re: Replace more characters using UDF
I mean have you got a string you want to change and a string that should be the result? But if you're happy then we have a result.
Lisa
Lisa
-
- PlatinumLounger
- Posts: 4931
- Joined: 31 Aug 2016, 09:02
Re: Replace more characters using UDF
Thank you very much Lisa for the solution. I like it and I will use it like that.
Best Regards
Best Regards
-
- 5StarLounger
- Posts: 964
- Joined: 08 Nov 2012, 17:54
Re: Replace more characters using UDF
Just as a taster....
VBS does not have a "Like" statement.
Here is a function to reproduce that....
Lisa
VBS does not have a "Like" statement.
Here is a function to reproduce that....
Code: Select all
Public Function IsLike(ByVal Input, ByVal Pattern)
If Input = "" Xor Pattern = "" Then
IsLike = False
Exit Function
End If
If Input = "" And Pattern = "" Then
IsLike = True
Exit Function
End If
With CreateObject("VBScript.RegExp")
.Global = True
.Pattern = "\+(?=\x5B*(?!\x5D))"
Pattern = .Replace(Pattern, "\+")
.Pattern = "\.(?=\x5B*(?!\x5D))"
Pattern = .Replace(Pattern, "\.")
.Pattern = "\{(?=\x5B*(?!\x5D))"
Pattern = .Replace(Pattern, "\{")
.Pattern = "\}(?=\x5B*(?!\x5D))"
Pattern = .Replace(Pattern, "\}")
.Pattern = "\((?=\x5B*(?!\x5D))"
Pattern = .Replace(Pattern, "\(")
.Pattern = "\)(?=\x5B*(?!\x5D))"
Pattern = .Replace(Pattern, "\)")
.Pattern = "\|(?=\x5B*(?!\x5D))"
Pattern = .Replace(Pattern, "\|")
.Pattern = "\?(?=\x5B*(?!\x5D))"
Pattern = .Replace(Pattern, ".")
.Pattern = "\*(?=\x5B*(?!\x5D))"
Pattern = .Replace(Pattern, ".*")
.Pattern = "#(?=\x5B*(?!\x5D))"
Pattern = .Replace(Pattern, "\d")
.Pattern = "\[!(?=\x5B*(?!\x5D))"
Pattern = .Replace(Pattern, "[^")
Pattern = "^" & Pattern & "$"
.Pattern = Pattern
IsLike = .Test(Input)
End With
End Function