cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Replace a full word that starts with certain characters

JensDeveloper
Contributor II

Hi, I am trying to replace the words that starts with โ€˜Auftโ€™ because somehow it changes the next two characters by ๏ฟฝ๏ฟฝ
Image Below:
image

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 1

koryknick
Employee
Employee

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')