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

157
Views
Javascript Regex to find a word started with or followed by anything other than a character or digit

I'm trying to find names of programming languages in text, I've tried for days to find the correct regex, but I can't find it. Also running into problems when the language is C++ or C# I want to match the name of the languages if it starts with or ends with anything other than letters or digits.

  reg = new RegExp("\\b[\\+" + language[element] + "] \\b", "gi");
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use

new RegExp("(?<!\\w)" + language[element].replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') + "(?!\\w|\\+{2}|#)", "gi");

See the regex demo if language[element] holds the C text. Details:

  • (?<!\w) - no word char allowed immediately before the current location
  • C - a C char
  • (?!\w|\+\+|#) - a negative lookahead that fails the match if there is a word char, or ++ or a # char immediately to the right of the current location.
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!