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

原文地址:https://www.cnblogs.com/airwindow/p/4626898.html