Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 686

How to search for more than 1 value using RegExp

$
0
0
I have a working VB scripts that currently search a single value under the session variable property_key and if match found it set to zero and exit. Now I am trying to modify the script so that it searches for three values in stead one.

Basically where I have the value = "Dept1", I need to replace it with something like value in "Dept1","Dept2","Dept3". If any of these three values match found set to 0 and exit.

Any assistant or direction greatly appreciated.


Code:

' define variables
'
dim Arguments, Property_Key, Value, returnData, result
dim instanceValue, instanceValues, instanceValueArray
Dim regEx, matchFound

' Session Property_Key information to test for
'
Property_Key = "SE_ssgnames"
Value = "Dept1"

' define Arguments object and return scripting dictionary of User Session returned data
'
set Arguments = Permission.Arguments
result = 1

' - retrieve return data for the dictionary item only for this Property_Key
'
returnData = Arguments(Property_Key)

' split the return data for processing
'
instanceValues = Split(returnData, ",")

' loop through and validate the Values for a match,
' when a match is found, set the result to 0 and exit the loop
'
Set regEx = New RegExp
regEx.Pattern = replace(Value, "\", "\\")
regEx.IgnoreCase = True

for each instanceValue in instanceValues
  '
  ' check for each value
  '
  matchFound = regEx.Test(instanceValue) ' Execute search.
  if matchFound then
    result = 0
    exit for
  end if
next

set Arguments = Nothing
set regEx = Nothing

' return the result
'
Permission.Exit(result)
'


Viewing all articles
Browse latest Browse all 686

Trending Articles