Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Noupe.com:
Getting Started with PHP Regular Expressions
Aug 24, 2009 @ 12:59:10

Noupe.com has posted a new guide to getting started with regular expressions in PHP. Regular expressions can be one of the most powerful tools at your disposal when used correctly.

The main purpose of regular expressions, also called regex or regexp, is to efficiently search for patterns in a given text. These search patterns are written using a special format which a regular expression parser understands.

They cover some of the basics - special characters and some examples using them (like $, d, and *) - before getting into the preg_* functions in PHP. They also include some handy examples to validate things like US zip codes, email format validation and removing duplicated words in a section of text.

tagged: regular expression tutorial preg

Link:

Developer Tutorials Blog:
Learn regular expressions in PHP
May 01, 2008 @ 13:48:05

On the Developer Tutorials blog, Akash Mehta offers some suggestions of resources and methods for learning how to use regular expressions in your PHP applications.

When it comes to quickly dealing with large blocks of data, batch processing operations or screen scraping, regular expressions are often the most effective solution. There's just one problem, though - learning them can be as hard as learning a new language altogether. Here's how to get off to a flying start.

He points you first in the direction of the preg_* functions then towards a few examples (like with mod_rewrite) and tools to help you understand how things match, like the regex tested extension for firefox and the regular expression cheat sheet on AddedBytes.com.

tagged: learn regular expression preg firefox extension cheatsheet

Link:

Making the Web Blog:
Becoming PHP 6 Compatible
Dec 05, 2007 @ 17:13:00

On the Making the Web blog, there's this post that talks about looking forward with your code and making it ready for when PHP6 comes around.

If you want to make use of PHP 6 when it comes, you're going to have to write your new scripts so they are compatible, and possibly change some of your existing scripts. To start making your scripts PHP 6 compatible, I've compiled a list of tips to follow when scripting.

There's only five things in his list (like "stop using magic_quotes" and "don't register long arrays") but the comments provide many more additional gotchas to look out for and new features that will be included.

tagged: php6 compatible registerglobals magicquotes arrays preg reference php6 compatible registerglobals magicquotes arrays preg reference

Link:

Making the Web Blog:
Becoming PHP 6 Compatible
Dec 05, 2007 @ 17:13:00

On the Making the Web blog, there's this post that talks about looking forward with your code and making it ready for when PHP6 comes around.

If you want to make use of PHP 6 when it comes, you're going to have to write your new scripts so they are compatible, and possibly change some of your existing scripts. To start making your scripts PHP 6 compatible, I've compiled a list of tips to follow when scripting.

There's only five things in his list (like "stop using magic_quotes" and "don't register long arrays") but the comments provide many more additional gotchas to look out for and new features that will be included.

tagged: php6 compatible registerglobals magicquotes arrays preg reference php6 compatible registerglobals magicquotes arrays preg reference

Link:

The Northclick Blog:
A comma is a comma is a comma...or is it?
Sep 20, 2007 @ 14:32:00

Internationalizing a website can bring all sorts of challenges, as Markus Wolff found out when working on a recent project:

When you're building international websites, there's always something new to learn. Especially if one of the languages your website is available in uses a character set different from anything you're used to. For jimdo.com, the greatest challenge as of yet is the chinese version.

His focus isn't so much on the content of the page but on one small character that caused him headaches - the comma. Unfortunately, it seems that Unicode has its own commas that don't quite adhere to the "normal" rules to make them easy to work with (and, in his case, split with a regular expression). The fix to the situation was simple, though - adding a "u" modifier after the expression made it Unicode-aware and split the information correctly.

tagged: comma unicode support regularexpression preg chinese comma unicode support regularexpression preg chinese

Link:

The Northclick Blog:
A comma is a comma is a comma...or is it?
Sep 20, 2007 @ 14:32:00

Internationalizing a website can bring all sorts of challenges, as Markus Wolff found out when working on a recent project:

When you're building international websites, there's always something new to learn. Especially if one of the languages your website is available in uses a character set different from anything you're used to. For jimdo.com, the greatest challenge as of yet is the chinese version.

His focus isn't so much on the content of the page but on one small character that caused him headaches - the comma. Unfortunately, it seems that Unicode has its own commas that don't quite adhere to the "normal" rules to make them easy to work with (and, in his case, split with a regular expression). The fix to the situation was simple, though - adding a "u" modifier after the expression made it Unicode-aware and split the information correctly.

tagged: comma unicode support regularexpression preg chinese comma unicode support regularexpression preg chinese

Link:

SitePoint PHP Blog:
The Joy of Regular Expressions [2]
Sep 27, 2006 @ 14:20:00

Harry Fuecks is back today on the SitePoint PHP Blog with part two of his "joy of regular expressions" series, continuing on from this previous entry.

He jumps right in, summarizing the first part in a small section before getting back into the examples:

  • Hunting for .jp(e)gs
  • Escaping Meta-Characters
  • Search and Replace
  • preg_quote()
  • preg_replace()
  • Word Boundaries, Word Characters...and everything else
  • Sub patterns
  • Spot the XSS Hole
  • eval() is evil!
  • preg_replace_callback()
As you can see, it's crammed with just as much infromation as the first part and covers a wide range of topics to help you get more in tune with your inner regular expression guru.

tagged: regular expressions joy example tutorial part2 preg eval meta regular expressions joy example tutorial part2 preg eval meta

Link:

SitePoint PHP Blog:
The Joy of Regular Expressions [2]
Sep 27, 2006 @ 14:20:00

Harry Fuecks is back today on the SitePoint PHP Blog with part two of his "joy of regular expressions" series, continuing on from this previous entry.

He jumps right in, summarizing the first part in a small section before getting back into the examples:

  • Hunting for .jp(e)gs
  • Escaping Meta-Characters
  • Search and Replace
  • preg_quote()
  • preg_replace()
  • Word Boundaries, Word Characters...and everything else
  • Sub patterns
  • Spot the XSS Hole
  • eval() is evil!
  • preg_replace_callback()
As you can see, it's crammed with just as much infromation as the first part and covers a wide range of topics to help you get more in tune with your inner regular expression guru.

tagged: regular expressions joy example tutorial part2 preg eval meta regular expressions joy example tutorial part2 preg eval meta

Link:

WebProNews.com:
Form Checking - Verifying Name Using PHP Ereg
Jun 23, 2006 @ 12:40:01

On WebProNews.com, there's a brief tutorial on using regular expressions, specifically for filtering "names" entered by users.

One important use of Regular Expressions (Regex) is to verify fields submitted via a form. In this article, we attempt to write an expression that is able to verify the user's first name, middle name, last name or just names in general.

The expression should allow names such as "Mary", "Mr. James Smith" and "Mrs O'Shea" for example. So the challenge here is to allow spaces, periods and single quotation marks in the name field and reject any other characters.

Their examples use the preg_* functions in PHP to work, first looking for any invalid characters in the string(s), then amending it to ensure that there aren't any numbers involved either. The few lines of code it takes are included as well.

tagged: regular expression form checking verify preg regular expression form checking verify preg

Link:

WebProNews.com:
Form Checking - Verifying Name Using PHP Ereg
Jun 23, 2006 @ 12:40:01

On WebProNews.com, there's a brief tutorial on using regular expressions, specifically for filtering "names" entered by users.

One important use of Regular Expressions (Regex) is to verify fields submitted via a form. In this article, we attempt to write an expression that is able to verify the user's first name, middle name, last name or just names in general.

The expression should allow names such as "Mary", "Mr. James Smith" and "Mrs O'Shea" for example. So the challenge here is to allow spaces, periods and single quotation marks in the name field and reject any other characters.

Their examples use the preg_* functions in PHP to work, first looking for any invalid characters in the string(s), then amending it to ensure that there aren't any numbers involved either. The few lines of code it takes are included as well.

tagged: regular expression form checking verify preg regular expression form checking verify preg

Link:


Trending Topics: