Wordpress drop down nav php problem

Hi all,

I have created a drop down nav using the following php:

// Add ID and CLASS attributes to the first <ul> occurence in wp_page_menu
function add_menuclass($ulclass) {
return preg_replace('/<ul>/', '<ul id="main_nav">', $ulclass, 1);
}
add_filter('wp_page_menu','add_menuclass');

This is ok because it adds main_nav to the first ul navigation. My problem is though that I also need to add ul id=sub_nav to the first child of the navigation which Im having some trouble doing, has anyone any suggestions on how I could achieve this?

Thanks in advance!

Kyle

I am not sure whether it is possible to find the first <li> in a <ul> from regular expression in PHP but if you are comfortable to do this with jQuery then it can be done after loading the page. But since it will add the class to the LI while loading it will look something strange. For that you can hide everything at first then show them with jQuery itself.

Again if there is a good solution with Regular Expression that is good and reliable as well.