<div id='x'>ThiIssss_SSSSMySites</div>
$('#x').text( $('#x').text().replace(/(?<=[a-zA-Z])(?=[A-Z])/, '_'))
The output expected is:
Thi_Issss_S_S_S_S_My_Sites
Basically first letter even if it is capital it should not be prepended with underscore. Rest all places wherever capital letter is found if it is not prepended with underscore then prepend, I tried lot of ways. Can we achieve this with regular expressions? Or should we need function to do this?
.split(/(?!^)_*([A-Z])/).filter(Boolean).join("_")<div id='x'>ThiIssss_SSSSMySites</div>orThiIssss_SSSSMySites?