简体   繁体   English

正则表达式只接受 7 种特殊字符

[英]Regex to accept only 7 types of special characters

In my react-native application, I have a requirement to accept 7 types of special characters in a string.在我的 react-native 应用程序中,我需要在一个字符串中接受 7 种特殊字符。 It could be all 7, few of them or none of them.可能是全部 7 个,其中很少或没有。

Special characters are (),@'/-特殊字符为(),@'/-

so the accepted string will be like following.所以接受的字符串将如下所示。

  1. ABcd()ef,/'-@sdf => accepting all 7 ABcd()ef,/'-@sdf => 接受所有 7
  2. ABcd(), => accepting few of 7 ABcd(), => 接受 7 个中的几个
  3. ABcddfg => accepting none of 7 ABcddfg => 不接受 7

How should I write this regex in java script?我应该如何在 java 脚本中编写这个正则表达式?

Perhaps you mean也许你的意思是

https://regex101.com/r/Vt9wmF/1 https://regex101.com/r/Vt9wmF/1

/[\w\(\),@'\/-]/g

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM