Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

camparing a string using a wild card

Status
Not open for further replies.

Biggorron

Technical User
Oct 5, 2010
3
CA
Hi there,

how do i campre 2 words using a wild car. if you look at my code below i am trying to compare 2 things and in the brackets is where it needs to be the wild card. however i try the * as a wild card but that doesn't work. i keep getting a runtime error: Type mismatch: '[string: "user("]'

if arrList(i) = "user("*")" then
wscript.echo arrList(i)
end if

also is there a way to dispaly just what's in the brackets or a way for me to split that string.

thx
 
Whatever it means:
[tt]if arrList(i) = "user([red]"[/red]"*"[red]"[/red])" then[/tt]
 
If that is what comparing with wild card means (!!!), simply this for case-insensitive comparing:
[tt] if strcomp(left(arrList(i),4),"user",1)=0 then[/tt]
or this for case-sensitive comparing:
[tt] if strcomp(left(arrList(i),4),"user",0)=0 then[/tt]
Regexp? I am not sure the op is ready.
 
thank you tsuji. what you gave me worked just as i was hoping. Could you possibly help me with the last part of my question.

also is there a way to dispaly just what's in the brackets or a way for me to split that string.

so what i have is something like this user(myname) and i want to beable to display just myname.

thx in advance.
 
You can do it like this.
[tt] if strcomp(left(arrList(i),4),"user",1)=0 then '4=len("user")
wscript.echo mid(arrList(i),5) '5=len("user")+1
end if
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top