Today 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:
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.
About 9 months ago I got a pre-paid AT&T GoPhone. Apparently the number that I got was one that belonged to a woman who, for reasons unknown to me, has fallen on what seems to be hard financial times (perhaps the reason why she doens’t have her mobile number any more). Since the time I’ve had the number, I’ve received many messages from bill collectors, schools, car warrantee providers, etc. all trying to reach this woman. I’ve been diligent about calling back these people and letting them know that their contact info is out of date so that they won’t call me back. Well, this morning I got a message from a gentleman that knows this woman, I assume. I wouldn’t do the message justice by trying to describe it, so here it is for your listening pleasure.
Warning: There are some expetives within, so if you are at work, you may want to use your headphones.
I 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 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: