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

142
Views
How to get a specific string in JavaScript

I have:

var text = 'LTE CSSR (East xr) (301-LT_King_St_PC)'

and I want to split from (East xr) (301-LT_King_St_PC) only as follow :

var result = text.split('(')
result = (East xr) (301-LT_King_St_PC)
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You can use a regular expression with the match function to get this done. Depending on how you want the result try one of the following:

var text = 'LTE CSSR (East xr) (301-LT_King_St_PC)'
console.log('one string:', text.match(/\(.*\)/)[0])
console.log('array of strings:', text.match(/\([^\)]*\)/g))

The first does what you seem to be asking for - a single output of everything between the first ( and the second ). It does this by searching for /\(.*\)/ which is a regex that says "everything in between the parentheses".

The second match splits it into all parenthesised strings using /\([^\)]*\)/g which is a regex that says "each parenthesised string" but the g at the end says "all of those" so an array of each is given.

about 4 years ago · Juan Pablo Isaza Report

0

You can do it using substring() and indexOf() :

var text = 'LTE CSSR (East xr) (301-LT_King_St_PC)';
var result = text.substring(text.indexOf('('));
console.log(result);

about 4 years ago · Juan Pablo Isaza Report

0

You're quite close with your current method. One way you could try this is to use multiple characters within your split

var result = text.split(") (") 
# Output -> result = ["(East xr", "301-LT_King_St_PC)"]

From here, some string manipulation could get rid of the brackets.

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!