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

332
Views
Removing Special Character in JavaScript

string = string.replace(/[^a-zA-Z0-9]/g, '');

Can anyone Explain this snippet (/[^a-zA-Z0-9]/g, '') ??? What it means? I know what it does. But how

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The snippet

string = string.replace(/[^a-zA-Z0-9]/g, '');

Uses RegEx (Regular Expression) to find a paten and then replace it.

This is how it works:

  1. The .replace function replaces a specific character or patern in a string (first argument) with another (second argument)
  2. The /[^a-zA-Z0-9]/g is the regex. a-z means lower case characters from a-z, A-Z means upper case characters from a-z and 0-9 means number characters from 0-9. The ^ means not, so, not a letter, uppercase letter or number. The g at the end stands for global meaning it will not just find one match for the patern but all the matches
  3. The empty string is what to replace the patern with. So if it is not a upper/lower case letter or number character it will be replaced with nothing

Read about RegEx here

about 4 years ago · Santiago Trujillo 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!