regex validation

Carina4
Tera Contributor

Hi! I've a question for my regex validation, I need to validate that the // or \\ can be inserted in the rest of the string but not at the first character.

I'm working with this regex but not allowed // or \\ at the rest of sentence.

Can somebody help me with my regex?

 

This is my expression regex = /^[A-Z0-9./]([A-Z0-9\-.()\s]{1,2}[A-Z0-9\-./()\s]?)*$/;

 

Thanks a lot!

3 REPLIES 3

Harsh_Deep
Giga Sage
Giga Sage

Hello @Carina4 ,

 

Please use this regex pattern 

pattern = /^(?!\/\/|\\\\).*/;

 

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.

Harish Bainsla
Kilo Patron
Kilo Patron

try the below regex

^(?!/[/\\])[\w\s.()-]*$

Dipen Wadhwana
Giga Guru

Hi @Carina4 ,

 

Sure, here's a regular expression pattern that satisfies your requirements:

^[^/\\][A-Za-z0-9.\/]*([\\/]{2}[A-Za-z0-9.\/]*)*$

Please mark my solution as helpful if it worked for you.