Jump to content

RegEx Replace Help


cyfer65

Recommended Posts

I need a lil help with a greasemonkey script im trying to make..I need it to take all the Forms in the source HTML <form>(.*)</form>And place them all before/above all the Tables in the HTML <table>(.*)</table>so originally it looks like this

<div><table></table><form></form></div>

I want to change it to this

<div><form></form><table></table></div>

How would I do this?

Link to comment
Share on other sites

Not vary good with regex expressions, the code doesnt work, i was just trying to match all the data between the the <form> and <table> tags but I cant seem to get it to work.. I think it needs to also include matching linefeeds or carriage returns in the (.*) brackets but I'm not familiar with this regex replace functions or variables..

var DIV = document.getElementsByTagName("div");for(i=0;i<DIV.length;i++){ DIV[i].innerHTML = DIV[i].innerHTML.replace(/\<form\>(.*)\<\/form\>/g, '');DIV[i].innerHTML = DIV[i].innerHTML.replace(/\<table\>(.*)\<\/table\>/g, '');}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...