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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 33

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

764 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