Showing posts with label Regular Expressions. Show all posts
Showing posts with label Regular Expressions. Show all posts

Tuesday, November 4, 2014

Advanced Regular Expression Features


If you want to employ all regular expressions constructs and features you can't make it with a simple shell command or a tool, but you need to use a programming language. I use Perl, because it has the best and longest established support for regular expression.

Parenthesized Subexpressions

Earlier, we saw that regex engines support metacharacters \1, \2, \3, etc. to refer to the text matched by parenthesized subexpressions. Perl and most other modern regex-endowed languages also provide a way to refer to the text matched by parenthesized subexpressions from code outside of the regular expression, after a match has been successfully completed.

Tuesday, July 29, 2014

Regular expressions Introduction

1. What is a regular expression?

"A regular expression is a pattern which specifies a set of strings of characters; it is said to match certain strings."[Ken Thompson]

From the English dictionary:

    pattern = (noun) a regularly repeated arrangement of something.
    to match = (verb) to be equal.

A regex can or cannot match a string and, if it does, can match the string once or multiple times.