Regex in Ruby

转载 2013年12月01日 22:07:04

Code is as follows:

if

"405511107@qq.com".match(/^([a-z0-9A-Z]+[-|\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\.)+[a-zA-Z]{2,}$/)
puts "Email address 405511107\@qq.com matches regex of email address"
else
puts "Email address 405511107\@qq.com doesn't match regex of email address"

end


Executed Result:

Email address 405511107@qq.com matches regex of email address

相关文章推荐

regex in SearchEverything

SearchEverythingUse the search edit to type in a search.Everything will display the results immediat...
  • tlaff
  • tlaff
  • 2016-11-01 10:13
  • 305

Characters in Regex expression

正则表达式(regular expression)描述了一种字符串匹配的模式,可以用来检查一个串是否含有某种子串、将匹配的子串做替换或者从某个串中取出符合某个条件的子串等。 列目录时, dir *....

lisa with match (regex) build in ( 1st version toward scan word)

(match  'main  'cb) (match 'printf 'cb) (match  'name  'cb)   (  match   ...

Understanding nil?, empty? and blank? in Ruby and Rails

When first learning Ruby and Rails, I often used the methods nil?, empty? and blank? incorrectly. Th...

How to install Ruby on Rails in Ubuntu 11.10

by Ramesh Jha on 2011/10/27   http://blog.sudobits.com/2011/10/27/how-to-install-ruby-on-rails-in-...

Metaprogramming in Ruby: It’s All About the Self

Metaprogramming in Ruby: It’s All About the Self November 15th, 2009 After writing my last post on...

The Safe Navigation Operator (&.) in Ruby

The most interesting addition to Ruby 2.3.0 is the Safe Navigation Operator(&.). A similar operator ...

Ruby socket programming in CloudFoundry

This part is some work of code analysis of CF. First, let's look at the ../vcap/common/lib/vcap/...

Watir In Action —— Setup note(Watir安装/Windows XP/Chrome 17/Ruby1.9.3-p0)

1.下载最新版本的Ruby 下载地址:http://rubyforge.org/frs/?group_id=167 本次安装使用:Ruby1.9.3-p0 http://files.rubyfor...

Design.Patterns.in.Ruby

  • 2012-09-10 12:18
  • 2.68MB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)