Reputation: 101
I have a regex pattern almost working in Javascript. The only problem is that I don't want to pick up '|' or '&' characters. Here is what I have at the moment.
/^!?[^:(){},'[]+-]+$|[a-zA-Z0-9-_]+/
Can anyone tell me what I need to do to stop the regex picking up these two characters as part of this? Thanks!
Upvotes: 0
Views: 97
Reputation: 786291
You can use a negative lookahead to avoid matching these characters in you input:
/^(?![^|&]*[|&])!?[^:(){},'[]+-]+$|[a-zA-Z0-9-_]+/
Upvotes: 1