Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

256
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda