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

80
Views
How to split string with specific condition in Javascipt

I'm trying to split string with "&&" operator. but in my string there is some data with the same "&&" operator which I don't want to split. so is there any way or logic to ignore that operator for split data.

string -

let str = "countryid == 45 && (payerid==82||payerid==84||payerid==79) && (fobid!=1&&fobid!=2)"

Code -

let breakCond = str.split('&&');

Result -

0: "countryid == 45 "
1: " (payerid==82||payerid==84||payerid==79) "
2: " (fobid!=1"
3: "fobid!=2) "

Expected Result -

0: "countryid == 45 "
1: " (payerid==82||payerid==84||payerid==79) "
2: " (fobid!=1&&fobid!=2) "
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

It seems you could simply include the white spaces.

let breakCond = str.split(' && ');

If that doesn't do it than you would have to create your own version of split with its own logic.

about 4 years ago · Juan Pablo Isaza Report

0

if there are always no spaces in the ones you want to keep. you can just use:

str.split(' && ')
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!