Home > doc > pcre 
 en fr de es it nl pl pt pt_BR mk sq ca hu cs tr ar fa id vi ja ru zh zh_TW eo
Previous  Next  Edit  Rename  Undo  Search  Administration  
THIS WIKI IS DEPRECATED AND IS READ-ONLY. THE NEW WIKI IS THERE.
Documentation  
Warning! This page is not translated.  See english version 
PCRE Pattern Syntax
Here is a brief quick reference to the more common patterns you can use in PCRE regular expressions. The most commonly used is ".*", meaning any number of any character. This is equivalent to the wildcard "*" in the shell.

QUOTING - To prevent a character from being interpreted as a pattern meta-character, quote it.

CHARACTERS - How to specify characters, non-printable or programmatically.

CHARACTER TYPES - Match based on type of character.

       In PCRE, \d, \D, \s, \S, \w, and \W recognize only ASCII characters.

GENERAL CATEGORY PROPERTY CODES for use with p and P

CHARACTER CLASSES - Match a range or set of characters. For example, "[abc]" would match either a, b or c.

POSIX named sets for use in character classes:

       In PCRE, POSIX character set names recognize only ASCII characters. You        can use Q...E inside a character class.

QUANTIFIERS - Use this to limit regular expressions to match as much or as little as possible. For example, given the string "The quick brown fox slyly jumped over the lazy dog", the pattern "T.*e" would return "The quick brown fox slyly jumped over the", while the pattern "T.*?e" would simply return "The". Possessive matches are like greedy ones, except that it evaluates all the way to the end of the string, and if there's more to the pattern after it, that part will be unfulfilled and the match will fail. "T.*+e" would not match the above string at all.

ANCHORS and SIMPLE ASSERTIONS - Match based on the position within the string.

ALTERNATION - Match any of several possible expressions.

CAPTURING - Return submatches.

COMMENT - You shouldn't need this in Gambas but maybe you're writing regular expressions to be used in several different languages.

OPTION SETTING - You should use the constants found in the Regexp class as arguments to the Compile or Exec methods to make your code more readable, but if you're generating regular expressions at run time, these may be useful.

BACKREFERENCES - Refer to previous submatches in the current match.

For more detailed information about the library, see http://www.regular-expressions.info/pcre.html or http://www.pcre.org. The above quick reference was adapted from the "pcresyntax" man page.