Quantcast
Channel: Regular Expressions VBScript using the OR Expression (|) - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Regular Expressions VBScript using the OR Expression (|)

$
0
0

I need to use regular expressions to parse a string.

Most times, the string can be parsed using the expression

^([a-zA-Z\-\,0-9\(\)\#\/ \.]{1,21})(.{0,9})(.{0,9})(.{0,9})(.{0,9})(.{0,9})(.{0,9})

Sometimes, the string needs to include an additional 4 characters so the expression would be

^([a-zA-Z\-\,0-9\(\)\#\/ \.]{1,25})(.{0,9})(.{0,9})(.{0,9})(.{0,9})(.{0,9})(.{0,9})

By themselves either expression would work on their respective strings. The first will also be technically valid on a string intended for the second expression, however the .{0,9} section of the expression would be off by 4 characters.

A quick explanation of the expression:Subset 1: 1 - 21 (or 25 characters)any characters a-zany characters A-Zthe dash, the commaany digits 0-9the open and close parenthesis, the hash tag, forward slash, space and period.Subsets 2-7Any characters (up to 9 total)

I was hoping for something like the expression below

^([a-zA-Z\-\,0-9\(\)\#\/ \.]{1,21|25})(.{0,9})(.{0,9})(.{0,9})(.{0,9})(.{0,9})(.{0,9})

OR

^([a-zA-Z\-\,0-9\(\)\#\/ \.]{1,21}|{1,25})(.{0,9})(.{0,9})(.{0,9})(.{0,9})(.{0,9})(.{0,9})

I tried these and they didn't work. Anyone else got any ideas?


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images