regex - VBS Compare strings using wildcard -


i have vbscript function requires string comparison one/both strings may include wildcard. unfortunately, strcomp("string1","string.*")=0 not work me doing comparison , seeing .* regex wildcard literal , not wildcard.

how go comparing 2 strings 1 and/or both include wildcard?

function:

function webtablecheck(pagename, tableproperty, rownum, colnum, checkvalue)    dim x, y, od, oc     x = split(tableproperty,":=")    if checkvalue <> ""         set od = description.create         od("micclass").value = "webtable"         od(x(0)).value = x(1)         set oc = pagename.childobjects(od)         y = oc(0).getcelldata(rownum, colnum)         msgbox(y)         if y=checkvalue             reporter.reportevent micpass, "webtable checkpoint", "the webtable checkpoint object """ &  checkvalue & """ found."         elseif  **strcomp(y,checkvalue,1)** = 0             reporter.reportevent micpass, "webtable checkpoint", "the webtable checkpoint object """ &  checkvalue & """ found, casing not match."         elseif strcomp(trim(y),trim(checkvalue)) = 0             reporter.reportevent micpass, "webtable checkpoint", "the webtable checkpoint object """ &  checkvalue & """ found, leading/lagging spaces not included in datatable and/or webtable cell found."         elseif instr(1,y,checkvalue,1)             reporter.reportevent micpass, "webtable checkpoint", "the webtable checkpoint object """ &  checkvalue & """ found., line break or other hidden character found in webtable."         else             reporter.reportevent micfail, "webtable checkpoint", "the webtable checkpoint object """ &  checkvalue & """ not found."         end if     end if end function 

you need use regular expression, here example.

line = "this text in to, contains searchpattern" set re = new regexp re.ignorecase = true re.pattern = "search.*tern" if re.test(line) wscript.echo "found" 

the .* regularexpression, . stands character, * stands none or multiple occurences of previous, use .+ here + meanbs @ least 1 occurence. can find multitude examples , sourcematerial regular expressions on internet, take in account vbscript uses not standard form sure include in search.

http://www.mikesdotnetting.com/article/24/regular-expressions-and-vbscript

http://www.regular-expressions.info/vbscriptexample.html


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -