symbols
can someone explain what all the "\/\*+#" etc stuff means? ie in bbcode:
PHP:<?php
//like this
$bold = '/(\[b\])(.+)(\[\/b\])/';
//and this
$html_entities_match = array('#&(?!(\#[0-9]+)#', '#<#', '#>#', '#"#');
?>
Login |
symbolssymbolsCurrently viewing this thread: 1 (0 members and 1 guests) symbols can someone explain what all the "\/\*+#" etc stuff means? ie in bbcode:
those are regular expressions. It is a really complicated system of finding specific criteria in strings I would suggest looking at PHP's PCRE documentation Just a short intro to what those specific ones do #&(?!(\#[0-9]+)# the # at the beginning and end are delimeters. They tell the regex parser to parse everything between # and # the & is saying look for a section of the string that starts with an & the (?!(\#[0-9]+ So basically it is saying Find any & that are not followed by a # and the numbers 0-9 with a ; at the end Here are some things the pattern would and would not match { would not match on the web text formatted like &#xxx; (where x are numbers) stand for special characters such as the copyright symbol, so the user wants to find a & that is not used for special characters Hope that helped ___________________ Neverside Development Director
http://regular-expressions.info is a good website if your just learning regex. It's not really PHP-specific, but more about regex as a whole. ___________________ I don't suffer from insanity; I enjoy every minute of it.
Regular expressions can be anything, really. When you're looking for a file, and you type in `find / -name "*.ext"`, that's a regular expression. These are a specific way to specify these sorts of expressions so that more complex matches can be generated, called Perl-Compatible Regular Expressions. They're pretty useful. There's also a couple of other implementations, like POSIX. :P I don't mean to be pedantic, but I think it's always a good idea to explain things in a broader sense before you narrow them down. ___________________ <3 Last edited by Noel, May 20th, 2006 08:44 AM (Edited 1 times) |
Copyright ©1999-2008 Neverside. All rights reserved.
Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach
NeverAPI generated this page in 0.0173 seconds.