Chapter 11. Working with Regular Expressions

Introduction

In this chapter

  • Writing regular expression objects

  • Writing regular expression literals

  • Understanding internationalization and regular expressions

  • Making legible regular expressions

A lot of the work of programs is in getting and processing information from an outside source, no matter whether the source is a file, a web site, a service, a stored object, or user input. You have to extract or manipulate the information that the input contains, so ActionScript 3.0 gives you specialized tools for working with certain kinds of data. In Chapter 10, you saw that ActionScript 3.0 has a special syntax for dealing with XML data, so when you get XML from an external source, you can count yourself lucky and use E4X to interpret and manipulate it easily. A lot of the time you aren't so lucky, and the input you have to deal with uses a format ActionScript 3.0 doesn't support, or it's free‐form. In order to help you deal with any kind of textual data, ActionScript 3.0 includes native support for regular expressions.

Introducing Regular Expressions

Regular expressions are fantastically cool. They are little programs inside your own program, written in their own very concise language. You can store them and use them over and over. You can use them to search through text, extract just the parts you want from a bigger piece of text, or replace parts of text.

With regular expressions, you can handle any kind of text with a regular grammar, from HTML ...

Get ActionScript™ 3.0 Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.