Showing posts with label pcre. Show all posts
Showing posts with label pcre. Show all posts

Thursday, July 19, 2012

Substract a string on a word boundry using regexp

There are many answers on this problem, but i found one very easy to implement, lightweight, and fast.
I think the fewer code lines, the better, so why not using a regexp instead of substr?

Thursday, June 14, 2012

Perl-compatible regular expressions in PHP

Perl Compatible Regular Expressions (normally abbreviated as 'PCRE') offer a very powerful string-matching and replacement mechanism that far surpasses any other search and replace function.

Regular expressions are often thought of as very complex—and they can be at times. However, properly used they are relatively simple to understand and fairly easy to use. Given their complexity, of course, they are also much more computationally intensive than the simple search-and-replace functions. Therefore, you should use them only when appropriate—that is, when using the simpler functions is either impossible or so complicated that it’s not worth the effort.