Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Understanding a RegEx expression
Message
From
11/03/2014 15:11:49
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01596120
Message ID:
01596140
Views:
39
>([A-Za-z0-9-]{1,20}) : at least one but less than 21 characters chosen from A to Z, a to z, 0 to 9 or the dash
>- : the previous group MUST be followed by a dash (so yes, it means it is supported from position 2 and up to 21, not supported in position 22)
>([A-Za-z0-9]{1,4}) : at least one but less than 5 characters chosen from A to Z, a to z, 0 to 9
>
>So all of the following are valid:
>-A-B
>--B
>ABC-DEF
>ABC--DEF
>AA--AB
>
>Which I am not sure is what you want, I think you do not want the dash in the first expression?
>
>NOTE: Position above refers to the relative position from the start of the matched string, if you want it to match only at START or/and END you must include ^ or/and $

Thanks

One thing for sure, the maximum amount of characters is 20. So, it cannot have a length of 21 or 22. Knowing that information, would there be something else to adjust from your message?

Also, it is confusing to me to interpret a 1,20 to be known as less than 21 characters instead of refering is as a length of 20.

So, basically, the dash following the first group is an expression. Then, we have a third expression to represent everything after the dash.

So, if we take this one: ([A-Za-z0-9-]{1,20})-([A-Za-z0-9]{1,12})

Does it mean that alphanumeric characters or a dash in positions 1-20 are accepted, a dash would be mandatory and would act as a delimiter to tell that the next 12 characters after have to be alphanumeric?

Where this: ([A-Za-z0-9-]{1,20})-([A-Za-z0-9]{1,4})

...would mean that alphanumeric characters or a dash in positions 1-20 are accepted, a dash would be mandatory and would act as a delimiter to tell that the next 4 characters after have to be alphanumeric?

What I wanted was to understand this expression so I can document it.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Reply
Map
View

Click here to load this message in the networking platform