background preloader

Ruby Regular Expressions

Ruby Regular Expressions
A regular expression is a special sequence of characters that helps you match or find other strings or sets of strings using a specialized syntax held in a pattern. A regular expression literal is a pattern between slashes or between arbitrary delimiters followed by %r as follows: Syntax: /pattern//pattern/im # option can be specified%r!/usr/local! # general delimited regular expression Example: #! This will produce the following result: Line1 contains Cats Regular-expression modifiers: Regular expression literals may include an optional modifier to control various aspects of matching. Like string literals delimited with %Q, Ruby allows you to begin your regular expressions with %r followed by a delimiter of your choice. # Following matches a single slash character, no escape required%r|/| # Flag characters are allowed with this syntax, too%r[</(.*)>]i Regular-expression patterns: Except for control characters, (+ ? Following table lists the regular expression syntax that is available in Ruby. #!

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

Related:  Ruby Tuts:

Ruby Regular Expressions: Ruby Study Notes - Best Ruby Guide, Ruby Tutorial Regular expressions, though cryptic, is a powerful tool for working with text. Ruby has this feature built-in. It's used for pattern-matching and text processing. 21 Ruby Tricks You Should Be Using In Your Own Code Writing for Ruby Inside, I get to see a lot of Ruby code. Most is good, but sometimes we forget some of Ruby's shortcuts and tricks and reinvent the wheel instead. In this post I present 21 different Ruby "tricks," from those that most experienced developers use every day to the more obscure. Whatever your level, a refresh may help you the next time you encounter certain coding scenarios. WebSockets on Rails 4 and Ruby 2 - Pogoapp WebSockets are an exciting new HTML5 technology which has finally begun to pick up enough browser, server and library support to see much wider adoption, potentially driving a move towards a signficantly new kind/kinds of web client/server communication. We've been making use of websockets with socket.io and node.js, but good old Rails doesn't need to be left out. We're going to use Dan Knox's slick high-level websocket-rails gem, and actually copy/port over a good bit of code from the slightly outdated example project. But why stop with WebSockets?

Regexp A Regexp holds a regular expression, used to match a pattern against strings. Regexps are created using the /.../ and %r{...} literals, and by the Regexp::new constructor. Regular expressions (regexps) are patterns which describe the contents of a string. Ruby for Newbies: Regular Expressions Ruby is a one of the most popular languages used on the web. We’ve started a new Session here on Nettuts+ that will introduce you to Ruby, as well as the great frameworks and tools that go along with Ruby development. In this lesson, we’ll look at using regular expression in Ruby. If you’re familiar with regular expressions, you’ll be glad to know that most of the syntax for writing the actual regular expressions is very similar to what you know from PHP, JavaScript, or [your language here]. If you’re not familiar with regular expressions, you’ll want to check out our Regex tutorials here on Nettuts+ to get up to speed.

74 Quality Ruby on Rails Resources and Tutorials Learning Rails from scratch can be a pain. But don't fret, this guide provides the best Rails resources the Web has to offer. Ruby on Rails is quickly becoming one of the most popular modern programming language framework combinations. Specifically, Ruby is a programming language that has been around for a few years and Rails is a framework for Ruby that is a bit newer and is just about the hottest thing in application and web development right now. Rails' seamless integration into web servers and databases and its elegant framework make it the ideal candidate for every programmer wishing to develop the latest and greatest web application.

Ruby Procs And Lambdas (And The Difference Between Them) As you know, I am a big believer in knowing the basics. I find it is especially valuable to go back to the fundamentals of whatever skill you're trying to master periodically, as you gain more experience. Somehow you're always able to extract something valuable from the experience due to the extra insight you've acquired along the way. Recently I've been looking more closely at some Ruby concepts that I may have glossed over when I was learning the language initially, so I will likely be writing about this in some of my upcoming posts.

Installing Ruby 1.9.2 on Ubuntu 11.10 Oneiric Ocelot without using RVM Installing Ruby 1.9.2 on Ubuntu 11.10 Oneiric Ocelot without using RVM It seems installing Ruby 1.9 on Ubuntu without the use of RVM isn’t all that trivial. I had to poke around the system for quite a while before I got it running. Why not RVM? Regular Expressions - A Gentle User Guide and Tutorial A Regular Expression is the term used to describe a codified method of searching invented, or defined, by the American mathematician Stephen Kleene. The syntax (language format) described on this page is compliant with extended regular expressions (EREs) defined in IEEE POSIX 1003.2 (Section 2.8). EREs are now commonly supported by Apache, PERL, PHP4, Javascript 1.3+, MS Visual Studio, most visual editors, vi, emac, the GNU family of tools (including grep, awk and sed) as well as many others. Extended Regular Expressions (EREs) will support Basic Regular Expressions (BREs are essentially a subset of EREs). Most applications, utilities and laguages that implement RE's, especially PERL, extend the ERE capabilities and what are typically called PERL Compatible Regular Expressions (PCREs) have, largely, become a de facto standard. Implementation documentation should always be consulted in case some wierd Regular Expression variant is involved.

UT on Rails Last year I held a series of non credit Rails courses for University of Texas Students, i’m happy to announce that i’ve been granted an Adjunct Professor position at the UT and I’m teaching a for credit course in Databases and Rails. Lucky for you, i’m a sucker for online learning, so i’ll be putting all my course material online, right here. The Course

19 Rails Tricks Most Rails Coders Don’t Know New to Rails 3? Check out the Ruby on Rails 3 Tutorial book and screencast. A book and screencast series showing you how to develop and deploy industrial-strength Rails apps in a direct, step by step way. The screencast series includes 12 lessons over more than 15 hours! Get the best "over the shoulder" experience of following what a top Rails 3 developer does when building an app today.

Related:  RegExp