ruby 正则表达式获取匹配字符串前后部分 Posted on 2012-02-13 In Ruby ruby 正则表达式获取匹配字符串前后部分 a = "Hello gagahappy Hi" refs = a.match(/gagahappy/) refs.pre_match # => "Hello " refs.post_match # => " Hi"