Home > Mobile >  How can I trim a string if input is Ramesh-123-india ...my desire output should be only "india&
How can I trim a string if input is Ramesh-123-india ...my desire output should be only "india&

Time:11-30

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:

1) You can make use of enter image description here

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.

  • Related