Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


VBScript regular expression

Posted on 2005-04-01
Medium Priority
Last Modified: 2006-11-18
Hey everyone,

I need to get a return from a string if it has  WIDTH:"xxx" or WIDTH="xxx" or WIDTH=xxx
case insensitive, where xxx >500 I need to know about it.

Can anyone help please?


Question by:noel58
LVL 10

Accepted Solution

ThaSmartUno earned 1500 total points
ID: 13683234
well you can use this ...

but using vbscript im not sure how to actually receive the number

LVL 34

Expert Comment

by:Big Monty
ID: 13683694
what will the whole string look like? will it change besides the xxx?

assuming the string is just the following, this should work for you:

str = "WIDTH=""xxx"""   'dont care about the : or =
strNew = Replace(str, """", "")   'get rid of any quotes

strNew = Right(strNew, 3)      'strip the last 3 digits off

if not Nan(strNew) then
   if CInt(strNew) > 500 then
      'do your thing here
  end if
end if

again, this will only work for the string definition above or if theres data before the WIDTH portion (str = "<input type=text WIDTH...."). in other words, if "xxx" or xxx are the last charactors of the string, this solution will work.


Expert Comment

ID: 13685578

Let's say you have the string in the variable STR:


tosearch = "WIDTH:" & chr(34) & "XXX" & chr(34) 'This is for WIDTH:"xxx"
if instr(temp, tosearch) >0 then
end if

tosearch = "WIDTH=" & chr(34) & "XXX" & chr(34) 'This is for WIDTH="xxx"
if instr(temp, tosearch) >0 then
end if

tosearch = "WIDTH=XXX" 'This is for WIDTH=xxx
if instr(temp, tosearch) >0 then
end if

'found=1 for WIDTH:"xxx"
'found=2 for WIDTH="xxx"
'found=3 for WIDTH=xxx

I didn't try it, I just wrote the code.

Author Comment

ID: 13691300
Thank thesmartuno, that regular expression was just what I needed
LVL 10

Expert Comment

ID: 13694511
you're welcome glad I could help

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Loops Section Overview
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question