怎样用正则表达式提取文字

来源:百度知道 编辑:UC知道 时间:2024/06/14 15:15:28
怎样用正则表达式把"http://passport.baidu.com/文字/a/b/f"字符串中的"http://passport.baidu.com/文字/a"串提取出来
我这是举个例子,具体字符串不定。
就是想取倒数第三个 / 之前的文字

(?<temp>http\:\/\/.*)\/.*?\/.*?\/\w+$
结果:temp:[http://passport.baidu.com/文字]
随便到数多少个,应该都可以。个人意见!

/http:\/\/\w+?\.\w+?\.\w+?\/.+?\/.+?/gi
就这样