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

130
Views
Analog operation for Python code to JavaScript RE Module

Here is the code :

        lines = re.split('\\s*\\n+\\s*', text)

        joint_stack = []

        for line in lines:
            words = re.split('\\s+', line)
            instruction = words[0]

My JS code is :

  _parse_hierarchy(text) {

    var lines = text.split('\\s*\\n+\\s*');

    console.log("Test _parse_hierarchy  -> ", lines);

I got array but i got whole text in one item. My array length is 1.

Looks like i need regex to split by line...

I also try var lines = text.match('\\s*\\n+\\s*'); with no success.

Any suggestion ?

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

0

Correct way for js format: \\ => \ and without ' or " .

    var lines = text.split(/\s*\n+\s*/);

    console.log("Test lines  -> ", lines);

   for (var key in lines) {

      var line = lines[key];
      console.log("Test _parse_hierarchy FIRST WORD  -> ", line);

      var words = line.split(/\s+/);
      // var firstword = words[0];
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!