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

262
Views
how to split on specific string in nodejs?

I want to split string for ">" but not when >> in JavaScript.

But once I am doing a split const words = str.split('>'); it is splitting >> as well.

Currently, after the split I look for "> >" and then substitute them with ">>".

How to implement it properly.

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

0

You can use a regular expression leveraging:

  • Negative lookbehind (?>!) causing a group to not be considered when the pattern matches before the main expression
  • Negative lookahead (?!) causing a group to not be considered when the pattern matches after the main expression

The resulting pattern would be as follows:

/(?<!>)>(?!>)/

Using the patter to tokenize an input would lead the desired results:

"here>>I>am".split(/(?<!>)>(?!>)/) // => [ 'here>>I', 'am' ]
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!