Developer Tools Mega List!
0Scott Hanselman has updated his list of developer tools for 2009. Check out the list of tools and see if you can improve your productivity!
XPath and Regex living together
0Today at work, I needed to come up with a regular expression that, given an xpath expression for a node, would return the xpath for that node’s parent. Originally, I wasn’t using regular expressions at all, but was just getting the substring of the xpath up to the index of the last occurrence of /
. This works fine, so long as the xpath expression doesn’t contain any conditionals that contain a /
, but what if you want to get the parent xpath from something like this:
/a/b[@x='/1/2/3']/c[@y='/4/5/6']
If the substring approach is used, /a/b[@x='/1/2/3']/c[@y='/4/5
is returned instead of /a/b[@x='/1/2/3']
! Hence the need for a regular expression.
I did some hacking around (as it turns out I was approaching things from the wrong point of view at first), did a few fruitless google searches, and finally gave up searching on regexlib.com.
Finally, I figured it out all on my own after an “aha!” moment of clarity.
^.+(?=(?<!\[[^\]]*)/)
Behold! What this is doing is a greedy match of any character up to but not including a /
that follows a [
without a ]
in between. I hope this will help somebody down the road who has a similar problem to solve.
The truth hurts
1Just got this e-card from my good friend Mike.
Thought this card seemed appropriate somehow — Happy New Year, and better luck in Nachos 2009!
–Mike
Revolution Money Exchange
0I know it’s a mouthfull, but it may prove to be a legitimate contender to PayPal. They don’t charge any fees for accepting money which is what attracted me to the service. Also, they are doing a referral program right now to get new users: $10 to both the referrer (up to $500) and the new user. Pretty sweet! Contribute to my referral fund by clicking on the image below and signing up for your own Revolution Money Exchange account.
I’m a man of many names
2I go out to eat lunch quite a bit and I’m often asked what my name is when I order. Most of the time the person behind the counter gets my name right, “Lance”. On occasion, however, they hear something different. Here’s a running list of my many names:
- Lens
- Lenz
- Lanz
- Lence
- Lents
- Lars
- Lons
- Rants (my personal favorite)
Recent Comments