Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to remove Characters from a string in react.js

I’m receiving data in this form

('FCA',)
('JP NIC',)
('JP CHI',)
('2022-03-04T07:18:36.468Z',)

I want to clean up to remove Brackets, string quote and comma

FCA
JP NIC
JP CHI
2022-03-04T07:18:36.468Z

I’m trying to use substring() But problem is number of characters in this data can be changed but these value are constant and I want to remove them ('',). How I can do this ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

you can use regex and string.replace

string.replace(/[|&;$%@"<>()+,]/g, "");

just put whatever string you want to ignore inside the rectangular brackets, i.e – string.replace(/[YOUR_IGNORED_CHARACTERS]/g, "")

you can read more about regex here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading