I am currently working with the following pseudo code block to fix a regex problem I am running into. currently I am using regex to find/remove various menu items based by id, however, it is only working for children, not the parent records. so in this example I am trying to remove id53 and if you run the pseudo code you will see it breaks the structure of the tree b/c it does not remove the entire <li></li> block.
anyone have any ideas on how to adjust the regex test pattern we are working with? I really appreciate your help and hope you have a great week.
<cfsavecontent variable="pseudo">
<ul id="nav-main-links">
<li class="standby" id="id61"><a href="/?event=User.Home.dspHome" target="_self" title="Home"> Home<font class="menuItemType">(CB)</font></a>
<li class="standby" id="id53"><a href="/contactus.cfm" target="_self" title="Contacts"> Contacts<font class="menuItemType">(L)</font></a>
<ul class="sub-nav-main-links nestingLevel1">
<li class="standby" id="id54"><a href="http://test/index.cfm" target="_self" title="Ven"> Ven<font class="menuItemType">(X)</font></a></li>
<li class="standby" id="id55"><a href="http://test/spEvents.cfm" target="_self" title="SponsorShip"> SponsorShip<font class="menuItemType">(L)</font></a></li>
</ul>
</li>
</ul>
</cfsavecontent>
<cfscript>
myDisplay=structnew();
myDisplay.pseudo=pseudo;
myDisplay.IdsToRemove="53";
myDisplay.RegExTestPattern='<li[^>]*?id="id(' & myDisplay.IdsToRemove & ')".*?li>';
myDisplay.Menu=reReplaceNoCase(myDisplay.pseudo,myDisplay.RegExTestPattern,"","All");
</cfscript>
<cfdump var="#myDisplay#">
Writing a regex solution would need a recursive regex, and I don’t know whether CFML supports that. As I commented, XML DOM manipulation is the way to go. It would look something like this (untested as I have no access to a ColdFusion server.