missing last character in perl regex

后端 未结 3 1229
情话喂你
情话喂你 2021-01-29 06:22

(log doggies) (log needs)

^\\(log (.*)[^)]\\)\\s*\\(log (.*)[^)]\\)$

It works with the exception of missing character at the end \"s\" as:

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-29 06:45

    The [^)] eats your s-es. Why do you need it?

    my $s = '(log doggies) (log needs)';
    say for $s =~ /^\(log (.*)\)\s*\(log (.*)\)$/;
    

    Output:

    doggies
    needs
    

提交回复
热议问题