Software

Developer Tools Mega List!

0

Scott 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

0

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:

/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.

Xoop it!

0

XoopItIf you’re one of the many people that uses Firefox and has a ton of pictures, videos, and attachments sitting disorganized in your massive Gmail inbox and/or archive (and don’t mind linking your account with a third party site) then the Xoopit Gmail plugin addon for Firefox is for you! It categorizes all of your media and allows you to search through it by date, sender, media type, etc. I’m finding it quite handy. The XoopIt service is in private beta right now, but I was able to get in using an invite from Mashable. A limited number of invites are also available from Download Squad and Lifehacker.

Go to Top