Javascript / jQuery replace last word in input box in tamil language?

I need to replace last word from input value

Im using this code,

Get_value =$(input).val();
new_word= "new word";

function ReplaceLastWord(Get_value, new_word) {
 return Get_value.replace(/\w*$/, new_word);

$(input).val(ReplaceLastWord(Get_value, new_word));

Its working, but only for english... i am using tamil laguage in input

$(input).val()="கோச்மேடிக்ஸ் ச்னக்க்ஸ்";

For this language i need use this code.


try this

     var lastWord = function(inputString,newstring) {

lastWord("கோச்மேடிக்ஸ் ச்னக்க்ஸ்",'hi');

​ ​

Live Demo

here inputString is input value and and newstring is word to replace with.

if this will help you mark this as answer

function ReplaceLastWord(Get_value, new_word) {
 return Get_value.substring(Get_value.lastIndexOf(" ") + 1) + new_word;


 ? How to use the file of UTF-8 format as a .srt file to show subtitle in mediaplayer?
 ? Querying and extracting a Unicode value from sqlite3 in Python
 ? Increase charset="utf-8" Font size in php/mysql site
 ? Tibetan and Devanagari ligatures not getting stacked properly using iText
 ? complex text layout of Indic scripts
 ? lxml unicode entity parse problems
 ? lxml unicode entity parse problems
 ? lxml unicode entity parse problems
 ? XML Python Parser thhrowing errors
 ? lxml not parsing unicode properly for HTML