I have this text in my mysql-database:
Hi
how are you?
Working (php):
echo $row['text'];
Now working:
<script>
test = "<?php echo $comment; ?>";
document.writeln(test.parseURL().parseUsername().parseHashtag());
</script>
The error is nothing printed.
The javascript function:
<script>
String.prototype.parseURL = function() {
return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&~\?\/.=]+/g, function(url) {
return url.link(url);
});
};
String.prototype.parseUsername = function() {
return this.replace(/[@]+[A-Za-z0-9-_]+/g, function(u) {
var username = u.replace("@","")
return u.link("http://url.com/"+username);
});
};
String.prototype.parseHashtag = function() {
return this.replace(/[#]+[A-Ö–a-ö0-9-_]+/g, function(t) {
var tag = t.replace("#","")
return t.link("/?p=tagga&q="+tag);
});
};
</script>
But if I have it without the line break so it works Hi! How are you?
Anyone know how I can solve this?