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

179
Views
how do i match a number with a letter directly after or before
const input = "2a smith road ";

const input 2 = "333 flathead lake road, apartment 3b"

const address = input.replace(/(^\w{1})|(\s+\w{1})/g, letter => letter.toUpperCase());

Output should look like this:

input = "2A Smith Road"

input = "333 Flathead Lake Road, Apartment 3B"
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

I think looking for a word character (\w), preceded ((?<=...)) by a word boundary (\b) and optional digits (\d*) should cover all cases:

const input = [
  "2a smith road",
  "333 flathead lake road, apartment 3b"
];

const capitalize = (s) => s.replace(/(?<=\b\d*)(\w)/g, l => l.toUpperCase());

input.forEach(s => console.log(capitalize(s)))

about 4 years ago · Juan Pablo Isaza Report

0

You can match 1 or more digits followed by a lower case char \b\d+[a-z]\b and uppercase the whole match

[
  "2a smith road",
  "333 flathead lake road, apartment 3b"
].forEach(s => console.log(s.replace(/\b\d+[a-z]\b/g, m => m.toUpperCase())));

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!