nbweb
V2EX  ›  问与答

问下修饰符的意思

  •  
  •   nbweb · Sep 29, 2021 · 1269 views
    This topic created in 1711 days ago, the information mentioned may be changed or developed.

    $test =~ m/aaa/bbb/mg

    这个 m 在这里是啥意思,书上说是么锚点,看不明白。

    3 replies    2021-09-30 10:58:56 +08:00
    marcong95
        1
    marcong95  
       Sep 29, 2021   ❤️ 1
    regex101.com 如是说:
    m The ^ and $ anchors now match at the beginning/end of each line respectively, instead of beginning/end of the entire string or input.

    就是开了 m 之后^$匹配的是每一行的行首行末
    24owls
        2
    24owls  
       Sep 30, 2021
    perlre 里面也有详细得解释
    https://perldoc.perl.org/perlre#m

    Treat the string being matched against as multiple lines. That is, change "^" and "$" from matching the start of the string's first line and the end of its last line to matching the start and end of each line within the string.
    24owls
        3
    24owls  
       Sep 30, 2021
    @24owls s/得 /的 / 😂
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2735 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 51ms · UTC 02:39 · PVG 10:39 · LAX 19:39 · JFK 22:39
    ♥ Do have faith in what you're doing.