DEV Community

Discussion on: Collab Lab Week 4 - Tuesday

Collapse
 
eggorybarnes profile image
eggorybarnes

You could try something like,

input.replace(/\s+\s/g, " ")

to replace all multiple spaces with a single space.

Collapse
 
nikema profile image
Nikema

I ended up using this afterall!

const normalizeName = name => {
  return name
    .replace(/[,.;:!-?]/g, '')
    .toLowerCase()
    .replace(/\s+\s/g, ' ')
    .trim();
};
Collapse
 
nikema profile image
Nikema

Thank you. We talked in slack about the acceptance criteria for this story and I'm going to change my approach. Instead of limiting to letters only, I'll exclude the punctuation. The product owner let me know that we need to be able to accept accented letters and numbers.