I'm newbie in VBScript and have a following task:
Get substring from specific string using vbscript.
The source string:
one two alksdjfkl <b> sdklifjklsdjf </b> <b:FileName>Test</b:FileName> jsdhfj rutyier x,mcvn,mcx </b> <b:FileName>Test2222.docx</b:FileName> mvbn,cmvb eiurtyeiurty
I need to get content between and I've tried following:
Set objRegExp = CreateObject("VBScript.RegExp")
Str = "one two alksdjfkl <b> sdklifjklsdjf </b> <b:FileName>Test</b:FileName> jsdhfj rutyier x,mcvn,mcx </b> <b:FileName>Test2222.docx</b:FileName> mvbn,cmvb eiurtyeiurty"
objRegExp.Global = True
objRegExp.Pattern = "^<b:FileName>*</b:FileName>$"
Set objMatches = objRegExp.Execute(Str)
msgbox objMatches.Count
For i = 0 To objMatches.Count - 1
Set Match = objMatches.Item(i)
msgbox Match.Value
Next
But I didn't get what I really need: Test.doc, Test2222.docx. It seems that I don't understand how regex specific symbols are working.
Could you please help me with this task?
Thanks in advance!
RegExpis a built-in VBScript object, you do not have to late bind to it using theCreateObject()method. the exception to this is if you are accessing it via VBA which can only access it through COM because it exists in the VBScript runtime.