For ex: I have input with this value: (099) 123 45 67
I want to replace the digits with underline (_) on deleting as this: (099) 123 __ __
How I do? I have the function which returns me the current character position. Then with charAt() I get the character and then replace it using replace(). But if there is more than one the same characters it replaces the first one, not the one which next to cursor.
Have any ideas?
I don’t think the standard
replace()function could accomodate this type of replace.You’d have to use
substring()to split the string into to (one string before the character and one after) and then concatonate them back together with the'_'in between.