News Feed
Jobs Feed
Sections

Recent Jobs

News Archive
feed this:

Debuggable Blog:
String substitution using UUIDs
August 22, 2008 @ 12:04:39

On the Debuggable blog, Felix Geisendorfer shows how to create a string parser that allows you to pull out parts of the string you don't currently want manipulated to be put back later.

If you've ever written any non-trivial String processing code, you've probably ran into the situation where you wanted to exclude certain parts of your string for a certain operation. Usually that would mean you have to tokenize your string, or adjust the operation you want to run so it doesn't affect the part of the string you want to exclude from it. Both of those solutions can be fairly time intensive so I was looking for a shortcut and found one.

He provides the code for this string substitution class, a method substitute() that matches based on a regular expression and, if found, stores the parts for later use.

0 comments voice your opinion now!
string substitution uuid manipulation regularexpression



MSBWare.com:
XML to Array
April 14, 2008 @ 10:23:11

Michael has posted a simple script today that takes in XML data and spits back out an array on the other side:

The function takes the specified XML data (which must be in valid XML format) and converts into an array. Any attributes in the XML elements are dropped an only the element values are placed in the array.

The code uses a combination of XPath, DOM, and regular expressions to parse the given XML content.

0 comments voice your opinion now!
xml translate array xpath dom regularexpression data element


Rails for PHP Developers:
Three New Articles Posted (Scope, Variables & RegEx)
February 19, 2008 @ 08:44:00

Mike Naberezny has posted a few more articles to the "Rails for PHP Developers" website (based on this book) covering some more of the basics.

There's three new tutorials posted:

  • Ruby Block Scope - the basics of Ruby block scope, a common point of confusion for PHP developers new to Ruby.
  • Variable Arguments - an article that shows two common API patterns found in Rails, variable arguments and option hashes, and how to implement them both in PHP.
  • Regular Expressions in Ruby - a useful reference that maps all of the common PHP regular expression functions to the equivalents in Ruby.

Check out the rest of the site for even more great content.

0 comments voice your opinion now!
rails development regularexpression variable argument scope ruby


PHP in Action Blog:
Tips for web testing
February 13, 2008 @ 08:09:46

On the PHP in Action Blog, there's a this post that shares some tips for testing your web applications with some simple tests.

I just started listing the techniques I've learned when writing tests to exercise the web interface of a PHP application. This is from my experience and my personal preferences; it's not the final word or necessarily right for everyone.

He suggests:

  • Use SimpleTest's Web tester if you can
  • Test the web output using regular expressions
  • Use element IDs or names to test links, forms and fields
  • Log HTTP requests in the application
0 comments voice your opinion now!
web testing unittest simpletest regularexpression http request


Reinhold Weber's Blog:
40 signs you really are a lousy PHP programmer
February 08, 2008 @ 15:23:00

Reinhold Weber has put together a list of signs (40 in all on his "programming list of shame") that you're a lousy PHP programmer. Here's a sampling:

  • don't see the need and/or benefits of a good programming IDE like Zend Studio or Eclipse PDT
  • have never used some form of version control like Subclipse
  • don't use a consistent methodology
  • don't use test-driven development
  • don't return content but echo or print it from your functions or classes
  • return HTML, not data, strings, or objects.
  • don't allow intelligent error handling
  • you think reusable software equals/requires your code to be OOP

Now granted, some of them are a bit more high level than others, but if you're not headed towards a lot of these, you might change paths, hop out of that comfort zone and branch out into the community and the language a little bit more.

2 comments voice your opinion now!
lousy programmer test optimize list oop intelligent regularexpression


SitePoint PHP Blog:
Tokenization using regular expression sub patterns
January 18, 2008 @ 11:15:49

On the SitePoint PHP blog there's a new post from Harry Fuecks talking about a replacement method using token that works a bit better than the typical regular expression method.

Promtped by a real world example, one often-overlooked feature of most regular expressions engines is how subpatterns can useful to whip up tokenizers relatively easily. The problem? I needed to match the word any of the words "Canton", "Region" or "Group" in a string and perform a follow up action depending on which matched.

His ultimate solution used a set of preg_match generated tokens to do the replaces a bit more reliably. It also makes it easy for other scripts (like his Python example) to use them too.

0 comments voice your opinion now!
regularexpression pattern token replace


The Northclick Blog:
A comma is a comma is a comma...or is it?
September 20, 2007 @ 09: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.

0 comments voice your opinion now!
comma unicode support regularexpression preg chinese comma unicode support regularexpression preg chinese


PHPBuilder.com:
PHP and Regular Expressions 101
June 04, 2007 @ 16:38:00

On PHPBuilder.com today, there's a new tutorial covering one of the more powerful things you can use in PHP to manipulate strings (and similar data) - regular expressions.

A regular expression is a specially formatted pattern that can be used to find instances of one string in another. Several programming languages including Visual Basic, Perl, JavaScript and PHP support regular expressions, and hopefully by the end of this primer you should be able to implement some basic regular expression functionality into your PHP pages.

They start with the basics of what they are and take a brief look at the two different types of functions that PHP has to offer for their use (the ereg* group and the preg* group).

0 comments voice your opinion now!
regularexpression tutorial introduction function regularexpression tutorial introduction function


Sean Coates' Blog:
PHP Pie?
February 19, 2007 @ 08:20:00

Sean Coates has created a simple version of a popular bit of Perl functionality and shares the code in hi slatest post - the "pie" ability to perform a search and replace, line by line, through a file using a regular expression.

I've often found myself looking for a PHP equivalent. Not to do simple substitutions, of course, but complex ones. And since I'm most comfortable with PHP, and a I have a huge library of snippets that I can dig out to quell a problem that I may have solved years ago, I've been meaning to fill this void for a while.

So, one evening, he came home and hashed out this version of the script. He includes the code in the post...it works on the command line and pulls in a file (though STDIN) and loops through the buffered version to perform the regex replace.

0 comments voice your opinion now!
perl pie parse regularexpression code example replace search perl pie parse regularexpression code example replace search


Pierre-Alain Joye's Blog:
Finally some new features are coming, zip-1.9.0 serie began
January 18, 2007 @ 10:48:00

Pierre-Alain Joye has posted about some long-awaited features that he's added to his zip PECL package:

After a relatively long period without features addition, I feel like it is time to add some long awaited features to zip.

The features added are:

  • Glob and pattern support - now possible to add files using a glob pattern syntax or regexp (pcre based)
  • getStatusString - returns the error message containing the system/zlib or zip error, handy while debugging
These features are still just in the alpha release, but he's included some code to help you become familiar with their functionality already - one using glob, the other the regular expression.

2 comments voice your opinion now!
zip pel package new functionality addfile glob regularexpression zip pel package new functionality addfile glob regularexpression



Community Events











Don't see your event here?
Let us know!


cakephp book conference example release developer mysql application database zendframework ajax security job framework PHP5 releases code PEAR zend package

All content copyright, 2008 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework