 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Debuggable Blog: String substitution using UUIDs
by Chris Cornutt 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.
voice your opinion now!
string substitution uuid manipulation regularexpression
PHP in Action Blog: Tips for web testing
by Chris Cornutt 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
voice your opinion now!
web testing unittest simpletest regularexpression http request
Reinhold Weber's Blog: 40 signs you really are a lousy PHP programmer
by Chris Cornutt 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.
voice your opinion now!
lousy programmer test optimize list oop intelligent regularexpression
SitePoint PHP Blog: Tokenization using regular expression sub patterns
by Chris Cornutt 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.
voice your opinion now!
regularexpression pattern token replace
Sean Coates' Blog: PHP Pie?
by Chris Cornutt 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.
voice your opinion now!
perl pie parse regularexpression code example replace search perl pie parse regularexpression code example replace search
|
Community Events
Don't see your event here? Let us know!
|