为此使用什么正则表达式 [英] What regex to use for this
本文介绍了为此使用什么正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在写一个正则表达式,可以找到
I'm writing a regex that will find either
- 1 个或多个点
.
..
...
....
后跟一个空格或根本没有跟随任何东西 - 1 个或多个问号
?
??
???
再次后跟一个空格或根本不跟任何东西
- 1 or more dots
.
..
...
....
followed by a space or not followed by anything at all - 1 or more question marks
?
??
???
again followed by a space or not followed by anything at all
我如何编写这个正则表达式,以便我可以这样做或那样做?
How do I write this regex so I can have it do this or that?
推荐答案
\.+ ?$
\?+ ?$
(你只需要用 \
转义 .
或 ?
以匹配它的字面意思,因为这些字符在常规中具有特殊含义表达式.)
(you just need to escape a .
or ?
with a \
to match it literally, since those characters have special meanings in regular expressions.)
如果您想匹配包含仅您的模式的行,请使用 ^
前缀.
Prefix either of these with ^
if you want to match lines containing only your pattern.
这篇关于为此使用什么正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文