In material table one of the column has to be trim ..for example input is ramesh-123-india ,the output should be come as only "india"....how to do this
CodePudding user response:
const str = "ramesh-123-india";
const result = str.match(/\w $/)[0];
console.log(result);
<iframe name="sif2" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
CodePudding user response:
Consider looking into the split()
.
JavaScript docs
You can pass in a string pattern that it searches for to split it up.