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

php[architect]:
Pro Parsing Techniques With PHP, Part Three Using Regular Expressions
Aug 29, 2018 @ 15:55:15

On the php[architect] site they've posted the latest part of their series of magazine excerpts sharing methods for parsing text with PHP. In this third (and last) part the author focuses on the use of regular expressions. This article was originally printed in the magazine's August 2018 edition.

This is the final installment of a set of three articles offering strategies for parsing text with PHP. The first article described the basics of parsing, followed by an article on developing fault tolerant parsing strategies. This article is dedicated to regular expressions.

Regular expressions, or sometimes simply called regex, represent a powerful set of tools which allow developers to split strings, perform character substitutions, and extract text based on matched patterns. The patterns, used in regular expressions, are an actual language that describe combinations of type castings and values that match the text you want to split, substitute, or extract. Regular expressions are an enormously powerful tool for the developer who understands them.

The tutorial starts by walking through some of the basics of what regular expressions are and the functions provided by PHP (using preg_*) to work with them (including basic code examples). It then briefly talks about pattern matching with regular expressions and gives a more specific example showing phone number extraction.

tagged: phparchitect august18 parsing text series part3 regularexpression tutorial

Link: https://www.phparch.com/2018/08/pro-parsing-techniques-with-php-part-three-using-regular-expressions/


Trending Topics: