开发者

RegEx get all characters before

I have this regular expression 开发者_Python百科to get urls:

(((ht|f)tp(s?))://)?(www.|[a-zA-Z].)[a-zA-Z0-9-.]+.(com|edu|gov|mil|net|org|biz|info|name|museum|us|ca|uk)(:[0-9]+)(/($|[a-zA-Z0-9.\,\;\?\'\+&%\$#\=~_-]+))

And I want to modify it so that when I call to make an array of the matched strings it will get everything before it as well. How can I do this?


Prepend ^(.*?) to the regular expression. That will set up a non-greedy match of all characters between the start of the input string and those matched by the rest of your expression.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜