Link to home
Create AccountLog in
Avatar of stroudtx

asked on

Replace Pattern in ASP VB

I have this string - it's a variable so it changes per product.

Coverlet Size : Twin (+$0) [SIL216], Sheets : No Sheets (+$0), Extra Sheets : Twin Graphite Fitted Sheet (+$277) [BEL811], Shams : Graphite Standard New Primrose Sham (+$134) [NPRI301], Accent Pillows : Graphite Silk Velvet Throw (18x18) Pillow (+$132) [SVMB734]

I want to hide the mfg info which is inside the brackets [ ]

I use asp vb and I know there is an easy way to do this. I've searched Google, but I can't find anything that would work for me?
Avatar of octavient

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of stroudtx


I can change the bracket to something else if it would make it easier to do? I just don't want to use () because they are used and I need them to stay.
Yes, I would definitely use something other than the bracket, if it's under your control.  Maybe the html brackets?  < >

Then your syntax would look something like this:

Set RegularExpressionObject = New RegExp

With RegularExpressionObject
.Pattern = "<[^>]+>"
.IgnoreCase = True
.Global = True
End With

strOutput = RegularExpressionObject.Replace(strOriginalString, "")
Set RegularExpressionObject = nothing
Your first solution worked perfectly so I elected to stay with the bracket - thank you! Awesome solution!