How to match a newline \n in a perl regex?

后端 未结 3 1119
太阳男子
太阳男子 2021-01-12 04:34

I want to match this line,

\'\'\'No Change Alarms Help & Information
3条回答
  •  礼貌的吻别
    2021-01-12 05:14

    $string_given =~ s/matching expression/sustitution/s;
    

    i think this will work,using the /s modifier, which mnemonically means to "treat string as a single line". This changes the behaviour of "." to match newline characters as well.

    In order to match the beginning of this comment to the end, we add the /s modifier like this:

    $str =~ s///s;
    

    Without the /s, it wouldn't match at all.

提交回复
热议问题