How can I match strings that don't match a particular pattern in Perl?

前端 未结 6 1545
别跟我提以往
别跟我提以往 2021-02-06 00:25

I know that it is easy to match anything except a given character using a regular expression.

$text = \"ab ac ad\";
$text =~ s/[^c]*//g; # Match anything, except         


        
6条回答
  •  生来不讨喜
    2021-02-06 00:58

    you can use index()

    $text = "ab ac ad";
    print "ac not found" if ( index($text,"ac") == -1 );
    

提交回复
热议问题