search

Home  >  Q&A  >  body text

linux - grep正则表达式如何进行最短匹配?

迷茫迷茫2786 days ago750

reply all(3)I'll reply

  • 大家讲道理

    大家讲道理2017-04-17 14:49:29

    This can be matched grep -o "ed2k[^"]*"

    [root@localhost oldlog.md]# echo '你的地址' | grep -o "ed2k[^\"]*"
    ed2k://|file|%E7%A1%85%E8%B0%B7.Silicon.Valley.S01E01.%E4%B8%AD%E8%8B%B1%E5%AD%97%E5%B9%95.HDTVrip.1024X576.mkv|348759100|04dc44e4978ea2d4dc9bf41b08829a3e|h=rfe5smulijxlmz7mgtpmn2bt3vmofk56|/
    ed2k://|file|silicon.valley.s01e01.720p.hdtv.x264-killers.mkv|843706966|3B4B08BD9C960B5B8F2372158F84B1AE|h=36632AROF43T63NSXFLIGSYEB4PNDEFN|/

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 14:49:29

    It is recommended to use some HTML parser to extract the a tag separately for matching, which can avoid the problem of multiple a's in one line

    reply
    0
  • 迷茫

    迷茫2017-04-17 14:49:29

    By default grep doesn't support non-greedy modifiers, but you can use grep -P to use the Perl syntax.

    How to do a non-greedy match in grep?

    reply
    0
  • Cancelreply