View Full Version : Resolved RegEx

09-30-2014, 10:59 PM
I am trying to make a regex that only allows letters/number/and forward slash
However there are a few exceptions:
Before and after the slash can only contain up to 1,9 characters and cannot start or end with a slash.
EG: 8ajsdl/kjadh which is valid.

Current regex i am trying is:
var patt = /^(([a-zA-Z]{1,9})+([\/]{1}[a-zA-Z]{1,9})+|([a-zA-Z]{1,9}))$/

10-01-2014, 02:10 AM
Background/why you want this, is always helpful.

Also, what problems is it giving you?

10-01-2014, 09:51 AM


Still, as I say, knowing why you want to do this, as well as what you see as the problem with what you currently have, could help us in answering your question.

10-01-2014, 12:54 PM
Oops sorry i forgot to put what the problem was.
If i place over 9 characters in the first part (here)/ads it still would be valid.

10-01-2014, 03:27 PM
In that case, how about:


There is a possibility that you may have better results employing 2 or more regular expressions, one to validate the sort of characters, another one or two to validate the number of characters in which positions, perhaps even, logic like:

if(passes one test){must also pass other test}else{must pass yet another different test}

if you get my meaning.

10-01-2014, 05:01 PM
Works great! Thanks:
For anyone else that wants it: