function html2entities() {
var a = /[(<>"'&]/g;
for (i = 0; i < arguments.length; i++) arguments[i].value = arguments[i].value.replace(a, function(a) {
return replacechar(a)
})
}
function replacechar(a) {
if ("<" == a) return "<";
if (">" == a) return ">";
if ('"' == a) return """;
if ("'" == a) return "'";
if ("&" == a) return "&"
};
<form><textarea name="data1" style="width: 590px; height: 200px"></textarea><br />
<input class="tec2" type="button" value="Convert" onclick="html2entities(this.form.data1)" onmouseout="this.className='tec2'" onmouseover="this.className='tec2 tec2hov'"><br />
<input class="tec2" type="reset" value="Clear" onmouseout="this.className='tec2'" onmouseover="this.className='tec2 tec2hov'"><br />
</form><br />
Hello, i have this code, but i need it to execute only on lines containing a certain number, for example "3". How can i do this? It probably needs some regex but i'm not much of coder :(
l.e. Sorry for not providing full code and all the details from the start I've made a snippet with the whole code.
What i need is when i enter a text like this:
3-c-<text>
ff4-"text"
6--&text&
aa3---"text"
to be converted intro:
3-c-<text>
ff4-"text"
6--&text&
aa3---"text"
(I would need to expand the code, to make it work with lines containing different numbers than 3, and other characters to be replaced, but i think i can do this on my own afterwards)