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

207
Views
javascript : get numbers after entry in string

I have a text and I want to search in text, find the word ,and then return the numbers after this word

for example :

this is a signal , entry : 2430 and side is short

I want to find entry and return 2430

how can I handle this?

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

0

Just use a simple regex:

const input = 'this is a signal , entry : 2430 and side is short'; 

const number1 = input.match(/entry\W+(\d+)/)?.[1]; // "2430"

const number2 = input.match(/santa\W+(\d+)/)?.[1]; // undefined
about 4 years ago · Juan Pablo Isaza Report

0

If you want it on 1 line:

text = 'this is a signal , entry : 2430 and side is short';
x = text.split('entry : ')[1].split(' ')[0]; // 2430
about 4 years ago · Juan Pablo Isaza Report

0

You can also do with indexOf and regular expression

const word = "entry";
const str = "this is a signal , entry : 2430 and side is short";

const index = str.indexOf(word);

if (index !== -1) {
  let result = str.slice(index + word.length).match(/\d+/)[0];
  console.log(result);
}

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!