?
Solved

VBScript regular expression

Posted on 2005-04-01
5
Medium Priority
?
278 Views
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?

Thanks

Simon
0
Comment
Question by:noel58
[X]
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
5 Comments
 
LVL 10

Accepted Solution

by:
ThaSmartUno earned 1500 total points
ID: 13683234
well you can use this ...
pattern="width[=\:][""\s]?([0-9])*[""\s]"

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

0
 
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.

B.D.
0
 

Expert Comment

by:pvg1975
ID: 13685578

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

temp=ucase(str)

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

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

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

'Where
'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.
0
 

Author Comment

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

Expert Comment

by:ThaSmartUno
ID: 13694511
you're welcome glad I could help
0

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