I would like to know the regex for not allowing string like
我想知道正则表达式不允许使用字符串
**Test
but string like
但字符串就像
*test, test,123,
is allowed. So basically start with 2 Asterix(*) is not allowed rest everything is allowed.
被允许。所以基本上从2开始Asterix(*)不允许休息一切都是允许的。
I have tried following regex expression
我试过跟随正则表达式
[^(\*{2})].* [^(\*\*)].* [^(\*\*)$].* ^(?!\*\*.*)
[^(\ * {2})]。* [^(\ * \ *)]。* [^(\ * \ *)$]。* ^(?!\ * \ *。*)
2 个解决方案
#1
4
Use negative lookahead at the start to avoid matching 2 stars.
在开始时使用负向前瞻以避免匹配2颗星。
/^(?!\*\*).*/
// or
/^(?!\*{2}).*/
#2
0
Using Regex 101 I managed to find any *
following a *
with this
使用正则表达式101我设法找到*之后*
(\*[^*]+.*)
and then I run an or
on the other strings like this
然后我运行一个或像这样的其他字符串
^((\*[^*]+.*)|([^*]+.*))$
#1
4
Use negative lookahead at the start to avoid matching 2 stars.
在开始时使用负向前瞻以避免匹配2颗星。
/^(?!\*\*).*/
// or
/^(?!\*{2}).*/
#2
0
Using Regex 101 I managed to find any *
following a *
with this
使用正则表达式101我设法找到*之后*
(\*[^*]+.*)
and then I run an or
on the other strings like this
然后我运行一个或像这样的其他字符串
^((\*[^*]+.*)|([^*]+.*))$