I am have the following code:
For User
@john -> <a href="homeurl/profile/john">@john</a>
For Hashtag
#hello -> <a href="homeurl/hashtag/hello">#hello</a>
But in the PHP hashtags have Turkish letters (on the title). So hastags slug sanitized from (title). And Turkish letters replace to basic latin letters.
Turkish Letters: ığüşöç
İĞÜŞÖÇ
(function($) {
$.fn.autolink_regex_map = new Array(
{
're': /((http|https|ftp):\/\/[\w?=&.\/-;#~%-]+(?![\w\s?&.\/;#~%"=-]*>))/g, // URLs
'replace': '<a rel="nofollow" href="$1">$1</a>'
},
{
're': /(([a-z0-9*._+]){1,}\@(([a-z0-9]+[-]?){1,}[a-z0-9]+\.){1,}([a-z]{2,4}|museum)(?![\w\s?&.\/;#~%"=-]*>))/g, // Email addresses
'replace': '<a rel="nofollow" href="mailto:$1">$1</a>'
},
{
're': /(^|\s)@(\w+)/g, // @-mentions
'replace': '$1<a rel="author" href="' + homeurl + '/profile/$2">@$2</a>'
},
{
're': /(^|\s)#(\w+)/g, // Hashtags
'replace': '$1<a rel="search" href="' + homeurl + '/hashtag/$2">#$2</a>'
}
);
$.fn.autolink = function() {
return this.each(function() {
var $this = $(this);
$.each($.fn.autolink_regex_map, function(i, obj) {
$this.html($this.html().replace(obj.re, obj.replace));
});
});
}
})(jQuery);
This image result on following code:
#değilmi -> <a href="homeurl/hashtag/de">#de</a>ğilmi
How to detect the Turkish letters and how to replace latin version for the url e.g.
<a href="homeurl/hashtag/degilmi">#değilmi</a>