1

How to verify a string that only permits numbers letters and the characters like '.', '/', '_', '-' and only permit 40 characters.

I was doing something like this REGEXP_LIKE(path, '[a-zA-Z0-9_./-]{2,40}$') but is not working good.

Can anyone help me with this regex?

2 Answers 2

3

Well, it won't limit to 40 characters because it isn't anchored to the beginning of the string. Try:

REGEXP_LIKE(path, '^[a-zA-Z0-9_./-]{2,40}$')

Other than that I don't see anything glaringly wrong with it, assuming of course that you do mean for the minimum length to be 2 characters.

Sign up to request clarification or add additional context in comments.

1 Comment

It won't limit to 40 without the ^ anchor because then it will match any time the 40 characters at the end of the string match; there could be 5K of gibberish before that and the regex would still find a match.
2

May be you need to add beginning of line special character ^, i.e.: ^[a-zA-Z0-9_./-]{2,40}$

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.