Jump to content
Sign in to follow this  
Cubehead

StringRegExp question

Recommended Posts

Hi, I would like to test something with this pattern "[a-z][a-z0-9_.-]{2,31}". How can I ensure that the string tested starts (or ends) with the pattern ? I've been trying to find the information in the manual (beta 3.2.1.10), without success.

Thanks in advance.

Share this post


Link to post
Share on other sites

Do you need a literal question mark or do you need to match a single character?

I would like to check if a string is a valid login which can be between 3 and 32 character long, containing alphanumeric characters, with a possibility of the dot, hyphen or underscore, and starting with a alphabetic character.

The pattern is matched, even if the string starts with a digit. Now that I think of it, maybe I should try an exclusion...

Edit : found the solution. I can use ^ for a starting anchor and $ for an ending one. So my pattern should be "^([a-z][a-z0-9_.-]{2,31})$". I think that this information should go into the manual.

Thanks for your time.

Edited by Cubehead

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...