Online
 
Friday, 09 January 2009
 
 
More article:
Related Content:

Your Ad Here

PCRE Modifiers
 
Article Index
PCRE Modifiers
Page 2

Remember when I mentioned that you need delimiters to specify a PCRE? If you were wondering why, here's an explanation. PCRE introduces the concept of "modifiers" that can be appended to a regular expression to alter the behavior of the regex compiler and/or interpreter. A modifier is always appended at the end of an expression, right after the delimiter. For example, in the following regex:

/test/i

the last i is a modifier.

There are many different modifiers. Perhaps the most commonly used one is i, which renders the regular expression non case sensitive. Here's an example of how it works:

<?php

$s = 'Another beautiful day';

echo (preg_match ('/BEautiFul/i', $s) ? 'MATCH' : 'NO MATCH') . "\n";

?>

If you execute the preceding script, it will output the word "MATCH", indicating that the regex succeeded because the i modifier made it not case sensitive.


Tags: Add more tags...,
This entry was posted on . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a comment. Tags: Simple PHP, Pear, Easy PHP, PHP Tutorial, PHP MySQL, XSLT, Sap Tutorial, CSS Tutorial, XSL FO Java, SQL Tutorial.
Users' Comments (0)

Comment an article
  Name
  E-mail
   Title
Available characters: 4000
 Notify me of follow-up comments
This image contains a scrambled text, it is using a combination of colors, font size, background, angle in order to disallow computer to automate reading. You will have to reproduce it to post on my homepage
Enter what you see:

No comment posted

Mobile Wallpaper 175
Statistic


Last Post

 
Top! Top!