hi how can we find and access the first letters that comes right after the replaceAll() ?
like we have : hi_my name is_reza => replaceAll("_"," ") => so now i want to access to (m) from my and to (r) from reza
id did try split() and indexOf() method but it just aiming one of underscores not all of them
4
Answers
thank you all . actually i was looking for a way to remove all underlines and replacing the first letter after them to be capital . so i used your solution to achieve that .
You can use
split
,slice
(start from index 1 to the end, because you don’t want the left part of the first ‘_’) andmap
(which execute over every element of an array) onhi_my name is_reza
like so :The get the first character(s) after
_
underscore, you could use:or with
/(?<=_)[^_]/g
Demo on Regex101.com
To change that letter after
_
(in order to capitalize it) and remove the underscore all in one go, you could use String.prototype.replace() like: