regex - How are these angled brackets breaking my regular expression? -


i'm trying capture contents of bespoke html-style tag within data.

then i'd replace contents , surrounding tag placeholder.

i'm using objmatch.value , objmatch.submatches(0) access "contents + tag" , "contents only" respectively. however, angled brackets of tag appear causing both of these return contents.

this breaks:

"<mytag\b[^>]*>(.*?)</mytag>"  

both objmatch.value , objmatch.submatches(0) return contents only.

this works:

...but if change angled brackets dollar signs, this:

"$mytag\b[^$]*$(.*?)$/mytag$"   

objmatch.value returns "contents + tag", , objmatch.submatches(0) returns "contents only". expected , desired.

can explain why is, , / or how can change regex pattern solve it?

full code

    dim oregex     set oregex = new regexp     oregex.ignorecase = true     oregex.global = true     oregex.pattern = "<mytag\b[^>]*>(.*?)</mytag>"        dim matches()     dim replacements()     dim i: = 0     dim objmatch      each objmatch in oregex.execute(stringtotest)        redim preserve matches(i)        redim preserve replacements(i)        replacements(i) = objmatch.value        matches(i) = objmatch.submatches(0)        = (i + 1)     next 


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -