Jump to content

RegEx Replace Help


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?

Edited by cyfer65
Link to post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...