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

257
Views
How to get character After space in javascript

I am working on Avatar component in react where I want to get the first character and character after space and give the result to the avatar and display the abbreviated version of the full name for example:-

var fullName = ahmed hosny;

//I am able to get the first character like this:- 

fullName.charAt(0).toUpperCase() // this prints 'A'

my question is how can I get 'H' from hosny ?? thanks

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

0

Use regex for this.

For first occurrence

console.log(fullName.match(/(?<= )./))
// returns [ 'h', index: 6, input: 'ahmed hosny', groups: undefined ]

For all occurrences

console.log(fullName.match(/(?<= )./g))
// returns array of all characters after space
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!