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

x
?
Solved

VBScript regular expression

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

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

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