Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Understanding a RegEx expression
Message
From
11/03/2014 15:51:42
 
 
To
11/03/2014 15:48:43
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:
01596147
Views:
37
>Yes, either of those should be equivalent. You may want to also add a ^ to the beginning and a $ to the end to ensure the matched string is from a single word and not a substring of a larger word. Depending on what you are doing with the regex, the parenthesis may also be unnecessary. They will store off those substrings as a match that can be retrieved later or used in a replace. If you are using the matching groups, you don't need them.

I am not aware of the ^ and $ characters. Can you give me an example of what it would give with the inclusion of those characters in that expression as per what you say:

([A-Za-z0-9]{1}[A-Za-z0-9-]{19})-([A-Za-z0-9]{1,12})

On that one, I have scaled it down to the following validations:

Accept alphanumeric characters at position 1
Accept alphanumeric characters or a dash for the next 19 characters
A dash is mandatory
The dash can only be from position 2
After the dash, only alphanumeric characters are accepted for a maximum of 12 characters
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
Next
Reply
Map
View

Click here to load this message in the networking platform