JSFiddle - React, Tailwind, and code Playground

by Pawan Singh Bisht

HTML

<!--==remove special character, and  white-spaces from the sentence.==-->
<p class="container">Click here on  me</p>
<!--==remove special character, and  white-spaces from the sentence.==-->

CSS

p{
  border: 1px red dotted;
}

JavaScript

$(document).ready(function(){
$('.container').click(function(){
var reM = '#my&*^*&%*&$^%&$%^$ #name656565__: ^*&**&^%%$^&__# is Pawan###__';

/*you can use given comment for slice the string sentence*/
//str = reM.replace(/[0-9`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/\s]/gi,'').slice( 0,4 );

str = reM.replace(/[0-9`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi,'');
//$( ".container" ).append(str);
alert(str);
});
});