eval inline to create a regular expression regex crypto text

notes and quirk solutions found over time
Post Reply
darknkreepy3#
Site Admin
Posts: 253
Joined: Tue Oct 27, 2009 9:33 pm

eval inline to create a regular expression regex crypto text

Post by darknkreepy3# »

here is a simple way to use inline evaluation to get javascript rolling out some regex code with strings without all the nasty escape sequences involved.

Code: Select all

<script language="javascript">
var newRowStr="abcabcabc";
var charO="a";
var charN="x";
document.write(newRowStr);
var reg1=eval("new RegExp(/"+charO+"/g);");
document.write("\n"+reg1+"\n");
newRowStr=newRowStr.replace(reg1,charN);
document.write(newRowStr);
</script>
Post Reply