Manoj Singh
Manoj Singh

Reputation: 7707

How to strip out particular text using VBScript

I have got below text as string

test = "<span class='convert'>USD 30</span>"

I need to write a function in VBSCript which will take above string as input and will return USD 30 as output.

Please suggest

Upvotes: 1

Views: 358

Answers (2)

user69820
user69820

Reputation:

If your input text is more complicated than the example you've given, I would recommend using an XML library such as MSXML to parse the text. Otherwise, you can use a regex

Const test = "<span class='convert'>USD 30</span>"
dim regex: set regex = new RegExp
regex.pattern = ">([^<]*)"
dim matches: set matches = regex.execute(test)
dim output: output = Empty
if matches.Count <> 0 then
    output = matches(0).submatches(0)
end if
Response.Write output

Upvotes: 0

Simmo
Simmo

Reputation: 3131

output = Replace (Replace(test , "<span class='convert'>",""),"</span>","")

Upvotes: 1

Related Questions