Recent Changes - Search:

Home Pages Pidgin   Azarennya (S|N) Mac Textanium Reference ToDo Food Local Edit

Local: Hide

Language: Hide

Fantasy: Hide

SciFi: Hide

Film: Hide

Music: Hide

REALbasic: Hide

ResourcesGarageUniversityWebRingForums:REALElfDataPlugins and Code:BKeeneyDeclareSubEinhugurJoeRestrepoTempelmannZAZ

Coding: Hide

Forums:PowWebPHPWebmasterCodingWalkersPerlIntroMonksPHPJavaScriptToolboxUnobtrusiveJavaScriptJavaScriptCompressorRegularExpressions (test)JSLintSQLCocoaCocoaBuilderCocoaDevCocoaLabAppleScriptBBSUserlandFaqintoshFileMakerFileMakerTipsFileMakerWorldFileMakerPlugins

Science: Hide

History: Hide

1421

News/Politics: Hide

Cults/Crime: Hide

ClambakeInfidels

Miscellaneous: Hide

RegularExpressions

Converting markup into HTML requires regular expressions.

SyntaxModifierspreg_replace()Tutorial

It might be worth going into "phed" and playing around with the "preg" functions (preg_match() returns 1 if a pattern is found, 0 if not) to test the viability of your regexps.

Finding a string beginning with a backslash

<?php
	$pattern = '/\\\\{{/';
	$string = 'A \\{{string {{here';
	preg_match ($pattern, $string, $matches, PREG_OFFSET_CAPTURE);
?>

Result (print_r($matches)):

Array
(
    [0] => Array
        (
            [0] => \{{
            [1] => 2
        )

)

Finding a string not preceded by a backslash

<?php
	$pattern = '/[^\\\\]{{|^{{/';
	// That is: Either find two braces preceded by a character that is not
	// a backslash, or find two braces not preceded by any character at all.

	$string = '{{A \\{{string {{here';
	preg_match_all ($pattern, $string, $matches, PREG_OFFSET_CAPTURE);
?>

Result (print_r($matches)):

Array
(
    [0] => Array
        (
            [0] => Array
                (
                    [0] => {{
                    [1] => 0
                )

            [1] => Array
                (
                    [0] =>  {{
                    [1] => 13
                )

        )

)
Edit - History - Print - Recent Changes - Search
Page last modified on July 26, 2007, at 10:55 AM