Powerful Regex

Online test Regex

http://rubular.com

 

An example

src="http:\/\/localhost:3000\/preveiw-tool\/iphone5-web\/b\/?node=706814011"

src[/.*preveiw-tool\/([^\/]*)/, 1]

src.scan( /.*preveiw-tool\/([^\/]*)/).last.first

 

Basic knowledge concerning Regex

http://www.tutorialspoint.com/ruby/ruby_regular_expressions.htm

 

Important concepts:

Group: specify in "()", could use capture to get all substring meet the regex in ()

 

posted @ 2015-07-07 14:27  airforce  阅读(110)  评论(0编辑  收藏  举报