Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
Thread: Regular Expressions
11-18-2009, 06:28 PM #1
- Join Date
- Nov 2009
- Traverse City, Michigan!
- Thanked 0 Times in 0 Posts
I'm currently working on remodeling an antiquated site. Part of the process involves adding page-based navigation (i.e. previous, next, home, etc.) at the top of each page, where originally it was only at the bottom.
Using my limited knowledge of Regular Expressions, I've already managed to update the code/styling for the existing navigation at the bottom (e.g. using Dreamweaver's Find and Replace with Regular Expressions to locate the tags in questions—anchor tags, for instance—and preserve the attribute data, while modifying class names, adding divs, etc.) and I even batch-added the structure for the navigation at the appropriate place at the top of the page. What I'd like to do now, is to copy the attribute information from the links at the bottom of the page (hrefs and whatnot) into the corresponding attributes in the navigation at the top of the page.
Here's an example of the code I'm working with:
<div class="pageNav-top"> <ul> <li class="previous-top"><a href="#">Previous</a></li> <li class="home-top"><a href="../../index.html">Home</a></li> <li class="needToKnow-top"><a href="needtoknow.html">What I Need to Know</a></li> <li class="maps-top"><a href="../../maps/index.html">Maps</a></li> <li class="next-top"><a href="#">Next Page</a></li> </ul> </div> <div id="textBody"> <div class="imagetitle" align="center">Watch the Video</div> <div align="center"><a class="flowplayer" href="../../hst111/10_civil-war/videos/Fort_Sumter_VP6_384K.flv"><img src="images/videostill-fort-sumter.jpg" alt="Fort Sumter" width="329" height="224" border="0"></a></div> <div align="center"><span class="caption">Video Length= 4:20</span></div> <h3>Fort Sumter</h3> <p>Having declared separate status from the Union, South Carolina (and other states) waited to see what response the Union would make. Lincoln forced the South to fire the first shot by announcing his intention to resupply a federal fort in Charleston harbor. If South Carolina allowed the resupply, the rebellion would be effectively ended. The Fort was bombarded heavily by shore emplacements before the Union resupply ships could arrive. Surrender followed in turn and the Civil War was officially underway. </p> </div><!-- end of textBody --> <div class="pageNav-bottom"> <ul> <li class="previous-bottom"><a href="election-1860.html">Previous</a></li> <li class="home-bottom"><a href="../../index.html">Home</a></li> <li class="needToKnow-bottom"><a href="needtoknow.html">What I Need to Know</a></li> <li class="maps-bottom"><a href="../../maps/index.html">Maps</a></li> <li class="next-bottom"><a href="early-war.html">Next Page</a></li> </ul> </div>
href="#") corresponding "Previous" and "Next" href attributes in the navigation at the top of the page, while ignoring any content (tags, text, or otherwise) in-between.
It seems like with RegEx's there should be a way to do this, but I'm not quite sure how. I know that I can find and grab the attribute values using something like this
href="([^"]*)", and then reference them with
$1, $2, etc., but I'm not sure how to only deal with the sections of the page that have the top and bottom navigation, while ignoring everything else.
Any help would be greatly appreciated!