我正在编写一个正则表达式来匹配一个或多个\
和一个或多个+
符号。
这就是我到目前为止看起来不正确的
/\\+\++/
my $test = "\+";
if( $test =~ /\\+\++/)
{
print "yes";
}
我已经尝试过这段代码而且无效
答案 0 :(得分:2)
对我来说很好看:
perl -Dr -e '"\\+++" =~ /\\+\++/'
Compiling REx "\\+\++"
rarest char + at 1
rarest char \ at 0
Final program:
1: PLUS (4)
2: EXACT <\\> (0)
4: PLUS (7)
5: EXACT <+> (0)
7: END (0)
anchored "\" at 0 floating "\+" at 0..2147483647 (checking floating) plus minlen 2
Omitting $` $& $' support.
EXECUTING...
Guessing start of match in sv for REx "\\+\++" against "\+++"
Found floating substr "\+" at offset 0...
Found anchored substr "\" at offset 0...
Guessed: match at offset 0
Matching REx "\\+\++" against "\+++"
0 <> <\+++> | 1:PLUS(4)
EXACT <\\> can match 1 times out of 2147483647...
1 <\> <+++> | 4: PLUS(7)
EXACT <+> can match 3 times out of 2147483647...
4 <\+++> <> | 7: END(0)
Match successful!
Freeing REx: "\\+\++"
答案 1 :(得分:0)