0

I have regular expression which is checking for at least one character or number:

^(?=.*[a-zA-Z])(?=.*[0-9]).*$

I want to add one more condition there to exclude forward slash:

I know that to exclude forward slash would be something like that [^/] but i don't know how exactly put it to my regex.

May be someone may help me with that?

1 Answer 1

2
^(?=.*[a-zA-Z])(?=.*[0-9])[^/]*$

That's all there is to it.

The dot . means "any character". The * repeats the previous token 0 or more times. So

[^/]*

means "zero or more non-slash characters", whereas

[^/].*

means "one non-slash character, followed by zero or more characters of any kind".

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

4 Comments

i tried like that but didn't took out the comma ^(?=.*[a-zA-Z])(?=.*[0-9])[^/].*$ , what comma means?
the last dot, this one before $, I quoted how i was trying to exclude forward slash
hehe, me as well, i mean dot not comma :)
when i leave the dot after [^/] this dot means what?

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.