macwadu
macwadu

Reputation: 907

pl/sql regex verification

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?

Upvotes: 1

Views: 157

Answers (2)

Kirill Polishchuk
Kirill Polishchuk

Reputation: 56162

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

Upvotes: 2

chaos
chaos

Reputation: 124277

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.

Upvotes: 3

Related Questions