V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
nbweb
V2EX  ›  问与答

问下修饰符的意思

  •  
  •   nbweb · 2021-09-29 11:39:10 +08:00 · 795 次点击
    这是一个创建于 937 天前的主题,其中的信息可能已经有所发展或是发生改变。

    $test =~ m/aaa/bbb/mg

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

    3 条回复    2021-09-30 10:58:56 +08:00
    marcong95
        1
    marcong95  
       2021-09-29 15:15:53 +08:00   ❤️ 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  
       2021-09-30 10:57:17 +08:00
    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  
       2021-09-30 10:58:56 +08:00
    @24owls s/得 /的 / 😂
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5767 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 01:51 · PVG 09:51 · LAX 18:51 · JFK 21:51
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.