Skip to main content

Posts

Showing posts with the label Quantifiers

Perl-style

The Perl programming language is exceptional at parsing strings by providing a comprehensive regular expression language to the programmer. Rather than creating their own regular expression language, the developers of PHP made the Perl regular expression syntax available to PHP users. The Perl-style regular expression syntax was built from the POSIX regular expression syntax and thus hold many of the same features. In fact, PHP programmers can use many of the same POSIX regular expression syntax when using Perl-style regular expression syntax. The basic Perl-style regular expression syntax involves using forward slashes (/ /) to identify the pattern that will be searched for: /mysql/ will find any string that contains the pattern "mysql", /m+/ will find any string that contains the letter "m" followed by one or more characters (mysql, mom, mudd, my, etc.) and /m{2,4}/ will find any string that contains the letter "m" followed by 2 or 4 character

POSIX

This form of regular expression searching is compliant with extended regular expressions (EREs) defined in IEEE POSIX 1003.2. Extended regular expressions are similar in syntax to the traditional Unix regular expressions, with some exceptions. The true power of the ERE's is their ability to be combined together to form searches. The POSIX ERE's are utilized in three methods: Brackets, Quantifiers and Predefined Character Ranges. •  Brackets -                      Brackets ([ ]) provide the capability to find ranges of characters when searching through strings. In non-extended regular expressions, when a search is made against a string for the term "dog", only words that contain the letters d-o-g in sequence are found. With brackets, the search using the [dog] will find any words that contain the letter "d", or the letter "o" or the letter "g". The following are a list of the most commonly used character ranges: ô€‚ƒ [0-9] mat