Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

259
Views
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 ?

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Use this regex:

const regex = /\('([^']+)',\)/g

const output = input.replace(regex, '$1');

//   explain:  /  \(  '  (   [^']+  )  ',\)  /  g

//             1   2  3  4    5     6   7    8  9
  • 1: start regex
  • 2: match character ( (character / to escape)
  • 3: match character '
  • 4: start group in regex
  • 5: match character not '
  • 6: close group in regex
  • 7: match ',)
  • 8: end regex
  • 9: make this regex match global (don't need if you want replace one time)
  • $1 in code is first group match regex (start with 4 and end with 6)

const input = `('FCA',)
('JP NIC',)
('JP CHI',)
('2022-03-04T07:18:36.468Z',)`;

const output = input.replace(/\('([^']+)',\)/g, '$1');

console.log(input)
console.log('// =>')
console.log(output)

about 4 years ago · Juan Pablo Isaza Report

0

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

about 4 years ago · Juan Pablo Isaza Report

0

You could use a regex replacement with a capture group:

var inputs = ["('FCA',)", "('JP NIC',)", "('JP CHI',)", "('2022-03-04T07:18:36.468Z',)"];
var outputs = inputs.map(x => x.replace(/\('(.*?)',\)/g, "$1"));
console.log(outputs);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!