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 ()

 

你可能感兴趣的:(regex)