Thursday, December 30. 2004PHP Regular Expression Problem
Happy Holidays!
One of my current projects is a small job search website. I have built a Google-style job display page that highlights the search terms. The search terms are turned into "stems" before the search, so I want to highlight all the words that contain that stem. For example, searching for "engineer" really searches for "engin" and I want to highlight "engineer", "engineers", "engineering", etc. To do this, I've used a regular expression: /\bengin(?:[[:alnum:]])*)\b/iThe \b term represents a "word boundary," which is supposed to be things that separate words, like spaces or periods. This expression worked really well until I wanted to highlight the term "C#". For some reason the pound sign plays havoc with the word boundary. Somewhere on the web I found the word boundary was defined as this expression: [^a-zA-Z0-9]*So I added a few characters to it to help out with "C#" and "C++", etc: [^a-zA-Z0-9_@\+\-#]*And my final regular expression became: /\bc#(?:[[:alnum:]])*)(?:[^a-zA-Z0-9_@\+\-#]*)/iThis will correctly highlight C# but for some reason, doing a preg_replace with this regular expression will eat the space trailing the highlighted word. It doesn't happen with the normal \b word boundary expression. I'm not enough of a regex guru to understand why this happens, or how to fix it. Any suggestions? Update 2005-02-05: I played around with this some more today. It turns out that preg_replace was going ahead and replacing the item from my word boundary expression, which explains why the trailing space or period would disappear. For some reason it doesn't eat the \b word boundaries. So I adjusted the expressions some, and this is what I came up with: /\b(c#[a-zA-Z0-9_@\+\-#]*)([^a-zA-Z0-9_@\+\-#]*)/iand then my preg_replace uses this: <span class="hilite">\$1</span>\$2The \$2 does the job of replacing my homemade word boundary. It seems to work properly. Woohoo! Friday, December 24. 2004McAfee Annoyances Part 2
I decided to get rid of McAfee's security/virus software from my two computers. Once your subscription expires, the software nags you incessantly. I was also annoyed that anytime I had to login to update via their website, it wouldn't work with Firefox and I had to use IE (stupid ActiveX). Plus, I didn't feel like paying $60 for a lousy one year subscription for two PCs.
Now that I uninstalled the McAfee software, I find that they left a stray program behind. The file is placed in C:\Documents And Settings\[my username]\Local Settings\Temp and is named for the time you uninstalled their software. Mine is called 2004122391919_mcinfo.exe on one PC. It is run on startup via a registry key called "msci" in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run. ZoneAlarm reported that it tried to access the internet. I suspect it was trying to phone home to tell them to nag me again by email, but I didn't let it happen. If it was just there to cleanup some files after a reboot, why did it want to connect to the internet? At any rate, the uninstall process should have informed me about it. This guy had the same problem and wrote out how to fully remove the McAfee software. All I had left to do after the standard uninstall was to delete the mcinfo.exe program manually (and the startup registry key), but shame on McAfee for leaving that little suspicious program there after an uninstall. So bye bye McAfee! I'm currently giving ClamWin a try, though I may go with AVG. Their stuff seems solid but I don't like their not-quite-standard GUI widgets. Thursday, December 16. 2004Comet Machholz
We're up in the cold north visiting our families for the holidays. My wife's parents' farm in eastern Ohio gets some pretty good night skies. I braved the chilly temperatures last night to find Comet Machholz in the sky near the feet of Orion. It was just a fuzzy ball in my binoculars, no tail or anything visible. Still, it's fun to find these somewhat-rare sights.
This comet was discovered by an "amateur" who now has 10 comets to his name. Here's his story about finding this one. Spaceweather.com has a sky map. There are currently some photos on a NASA site. Supposedly the viewing will get better in January, so I might try to photograph it then. Update 2005-01-03: Back in South Carolina now and we finally got a clear moonless sky. The stars were very bright tonight and I was able to spot the comet fuzzball with the naked eye. I also tried it through binoculars and even my childhood telescope, but it just made it a bigger fuzzball; I couldn't make out any of the tail. Updated SpaceWeather.com map and a good photo from an observatory. Wednesday, December 8. 20042003 Southeast Arizona Trip Story & Pictures PostedI finally got around to scanning photos and posting a little writeup for my Southeast Arizona trip, over a year ago. Someday I'll catch up with the old trips and photos! Click here to read the story and see the photos. (After blogging for most of a year, I'm still debating as to whether a trip warrants its own web page, or I should just post it as a blog entry. It's so much less effort to post to the blog, but since this trip was so long ago I put it with the old trip reports.) Monday, December 6. 2004ZoneAlarm Nags
ZoneAlarm seems to come out with an update every few months. The update usually claims to offer better stability and safety against new attacks. Maybe it does, but I have to wonder if the updates are not part of a campaign to get you to upgrade to their "Pro" version. Each time I download and install their update, I have to go through the whole annoying setup process: Yes, I just want to install standard ZoneAlarm; no, I don't want to see the tutorial; ok, I guess I'll restart my computer; no, I don't want to see the other tutorial either; yes, I'm sure. And that's skipping some of the steps...there are at least a dozen mouse clicks and a lot of waiting in there too.
I wonder if I bought the "Pro" version if it would nag me this much. I'd be willing to pay for a good firewall program that could install its updates without this much hassle. Or do I dare try the Windows XP SP2 firewall? Saturday, December 4. 2004Removing Dust with Photoshop
I've been scanning old slides and negatives lately. No matter how much I try to clean the film and the scanner, each scan ends up with visible dust marks.
I used to use the Photoshop clone stamp tool to copy a nearby color over the dust mark, but I found a method that I like better on this page. It's still a tedious process depending on the amount of dust in the scan, but the new method is a little easier. But if I ever shell out for another film scanner, I'm getting one with dust removal built-in to the software! I hope to have some new photos online soon.
(Page 1 of 1, totaling 6 entries)
|
CategoriesQuicksearchSyndicate This Blog |