Just wanted to share some regular expression (regex) patterns that I have come up with recently for a project I’ve been working on for a client.
These are currently prepared for use in PHP’s PCRE functions, but for the most part should work with minimal tweaking in any other language that accepts PERL regex.
/<([a-zA-Z]*)( [^>]*?)?>(\s*)<\/\1>/ - matches empty HTML tags.
/ Delimeter required in PCRE.
\< Escaped opening bracket (needs to be escaped in PHP).
([a-zA-Z]*) Matches 0 or more continuous alpha characters.
( [^>]*?)? Zero or more of any character except a closing bracket. This will give us attributes. The first ? means ungreedy for the 0 or more pattern. The second ? means 0 or 1 occurrences of the preceding pattern.
\> Closing bracket of the tag, needs to be escaped in PHP.
(\s*) 0 or more whitespace characters, this includes newlines.
\<\/ Escaped opening bracket for closing the currently open tag.
\1 Capture group reference to the matched pattern found at the beginning, this is the HTML tag we matched, so we close the correct tag.
\> Escaped closing bracket for closing tag.
/ Delimiter to end the pattern.
I’m not a regex expert, so I am sure there is room for improvement here, so please feel free to comment with fixes or adjustments.
Filed under regex regular expressions strip html php pattern matching
The biggest annoyance I have in Mac OS X Lion is when I try to use a full-screen app I lose the quick Command+H keyboard command. Since I like to reach for the mouse as little as possible, this leaves me Command+Tabbing to some non-specific app on my “home” Space.
I assume Apple removed Hide functionality from full-screen apps because there is nothing waiting behind them, but doing so killed a well-established workflow.
So I am proposing that Command+H essentially becomes the equivalent of hitting the Home Button on your iOS device. On your iOS device it basically hides whatever app is in the foreground, and if nothing is currently running it returns you to your main [iOS] Space.
Now assume Command+H works as it always has, however, if you are in a full-screen app, or a currently empty space, it returns you to your main space. In this case, Command+H could also be thought of has Command+H[ome].
If you are with me, please file feedback to Apple at http://www.apple.com/feedback/macosx.html
Filed under Mac OS X Lion Command+H full-screen apps Feedback
Excellent movie that inspired one of the greatest games of all time.
Filed under big trouble in little china lo pan mortal kombat
History is doomed to repeat itself. Get ready for lower data caps, poorer service and a larger company that has even less reason to care about the customer.
Filed under ma bell att tmobile monopoly
I wrote this a few years ago, it’s been passed around various code sharing sites, but I figured I should put it here as well.
It was meant to make the action of updating multiple custom form fields a single query. I personally have no idea if running this query is more intensive than just having multiple UPDATE calls under heavy load, but it was handy when I needed it.
UPDATE table
SET var = (CASE form_field_name
WHEN 'key1' THEN 'val1'
WHEN 'key2' THEN 'val2'
WHEN 'key3' THEN 'val3'
ELSE var // default to var's original value
END)
WHERE form_field_name IN ('key1', 'key2', 'key3')
Filed under code, development, mysql sql custom fields
Why, it’s my RAID being degraded as drive 5 fails, of course. What did I learn today? Well, most importantly that I need to figure out a way to disable this beeping alarm when drives error so the neighbors don’t call the police. Second, that it proved to be extremely beneficial to have a hot spare installed on the card.
Fortunately my Areca RAID card allows for more drives than I could afford at the time of purchase, so I didn’t have to debate about loading it to the gills with storage space and decided to add the hot spare. However, now I face a new conundrum, since I have to go through the hard drive buying process (which to me is like my girlfriend buying a handbag, I always want more than one), I just have to decide if I now want to fill it up with additional store or perhaps another hot spar. With 8 ports, and only 5 filled (including my replacement hot spare), do I use this as an excuse to add capacity and redundancy? Or am I merely opening myself up for more failure?
If I am going through this torture for just a home-project, I don’t look forward to when this happens at work…
Filed under hard drives failure raid 5 areca linux file server
While we are at it, let’s cut all funding to public schools and let them compete in the marketplace. Personally, I look forward to my kids watching Cheaters, Jerry Springer, and Days of Our Lives instead of that socialist Big Bird and Bert and Ernie forcing their non-Biblical lifestyle upon them.
Unfortunately, I don’t think dropping test scores, illiteracy or lack of culture will matter to most, not as long as they can get a low paying factory job building jets for the sectors that didn’t get any cuts.
Thank you, for saving me my $1.35, House of Representatives.
Filed under PBS Big Bird Idiocracy Corporatism