Sign in to follow this  
Followers 0
Cubehead

StringRegExp question

4 posts in this topic

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?


Who else would I be?

Share this post


Link to post
Share on other sites

#3 ·  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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

"(?i)(\a[\a\d._-]){2,31}"

Edited by this-is-me

Who else would I be?

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  
Followers 0