Forum Discussion

JensDeveloper's avatar
JensDeveloper
Contributor II
4 years ago

Replace a full word that starts with certain characters

Hi, I am trying to replace the words that starts with ‘Auft’ because somehow it changes the next two characters by ��
Image Below:

I’m not a professional in regex expressions so I am trying to learn it but I can’t come up with the solution. I always taught you could do $title.replaceAll(‘Auft’.*, ‘Auftragge’)

1 Reply

  • replaceAll() is expecting a string literal, so it is looking for a period and asterisk to follow Auft.

    I think what you want is the replace() method using an expression. This would be something like the following:

    $title.replace(/Auft.*/g, 'Auftragge')