Regular expression with jQuery codes?

How do I use the following regular expression with jQuery codes?

document.body.innerHTML = document.body.innerHTML.replace(/\<hr (class=“?seperator”?)\s?\/?\>/ig,‘<div $1></div>’);

console.log is a common way to record information to the javascript log. It’s common across Firefox, Google Chrome, and Opera.

There is also for IE a faux console that you can use too.

Thank you. Is consol.log a Firebug related code?

Can someone explain what consol.log is?

Hi,
Just for the sake of it :slight_smile:


console.log($('body').html().toString().replace(/\\<hr (class="?separator"?)\\s?\\/?\\>/ig,'<div $1></div>'));

I prefer the other way
Bye.

Before you do anything else, please correct the spelling to separator. Also, is this DIV going to be empty? If you’re just using it as an empty separator, that’s not appropriate use of the element (HR is better, or just CSS). Anyway, what you’re after is simple enough:

$('hr.separator').replaceWith('<div class="separator"></div>');

Thank you. I mean I want to use regular expression in jQuery, rather than replace regular expression with jQuery manipulation codes. For example: (I know this doesn’t work, just showing what I mean)

$(‘body’).html($(‘body’).html().replace(/\<hr (class=“?separator”?)\s?\/?\>/ig,‘<div $1></div>’));

P.S. The code at the very beginning is just an example showing what kind of code I want to use jQuery to replace with. I never write <hr class=“seperator” /> or <div class=“separator”></div> in the HTML source.

Thank you. I mean I want to use regular expression with jQuery, rather than replace regular expression with jQuery manipulation codes. For example: (I know this doesn’t work, just showing what I mean)

$(‘body’).html($(‘body’).html().replace(/\<hr (class=“?separator”?)\s?\/?\>/ig,‘<div $1></div>’));

P.S. The code at the very beginning is just an example showing what kind of regular expressioin I want to use with jQuery. I never write <hr class=“seperator” /> or <div class=“separator”></div> in the HTML source.