Jump to content

Recommended Posts

Posted

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.

Posted (edited)

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...