Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

59 users online



symbols

symbols

Currently viewing this thread: 1 (0 members and 1 guests)


sapphire

sapphire

Neverside Newbie
Status: Offline!

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]+Wink)#''#<#''#>#''#"#');
?>

BigToach

BigToach

Neversidian
Status: Offline!

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]+Wink is saying but dont find & that are followed by a # (the middle # doesnt count because it is escaped with a backslash \#) and numbers

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

&#123; would not match
&myass would match
&nbsp; would match
&#123; 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
PHP Snippets
BigToach.com - IT WORKS, TOACHY!

sapphire

sapphire

Neverside Newbie
Status: Offline!

Man, you're a php genius!

Kickboy

Kickboy

Neverside Newbie
Status: Offline!

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.
Unintended Theory | Cacrew v4

Noel

Noel

Nobody fucks with my title.
Status: Offline!

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. Smile

___________________

<3

Last edited by Noel, May 20th, 2006 08:44 AM (Edited 1 times)

phpmonkey

phpmonkey

whoa, wtf?
Status: Offline!

Regex is merely an implementation of a state machine. yadada bla bla bla

___________________

Fomerly known as lasnaranjas. Holler.
http://card.mygamercard.net/gelsig/blackdood.png

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0081 seconds.