Monday, 15 March 2010

regex - Regular Expressions VBScript using the OR Expression (|) -


I have to use regular expressions to parse a string.

Most of the time, the string can be parsed using expressions

  ^ ([a-zA-Z \ - \, 0-9 \ (\) \ # \ /.] {1,21}) (. {}} (. {0}} (. {}} (. {0}} ({19}) Sometimes, Additional 4 characters are required to be included, so that expression will be  
  ^ ([a-za-z \ - \, 0-9 \ (\) \ # \ / \. \. {1,25}) (. {}} (. {0}} ({0}} (. {0}} (. {}} (. {0}}   

The expression itself either works on their respective string. The first one also technically prepares for another expression The string will be valid, although the {0} portion of the expression will be off with 4 characters.

 A quick description of the expression: subset 1: 1 - 21 (or 25 characters) Any letter of any letter AAZ EzDash, Comma Any 0-9 open and close brackets, hash tags, forward slash, space and duration subset 2-7 any letter (up to 9 total)  

I like something for the expression below Was expecting

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

OR

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

I tried them and they do not work. Anyone have any ideas?

This is necessary, but I think you have to:

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

The first capture group must be either 1-21 characters or 25 characters long.

If you change How do your groups get caught (and if your Reggae engine supports it), you can also:

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

No comments:

Post a Comment