View previous topic :: View next topic |
Author |
Message |
smarty-user Smarty Rookie
Joined: 08 Apr 2014 Posts: 5
|
Posted: Tue Apr 08, 2014 2:24 pm Post subject: regex_replace: Replace ö ä ü with oe ae ue in smarty vars |
|
|
Hello! How can I replace ö ä ü with oe ae ue in smarty variables. I try to use the modiefier regex_replace but it don't work:
|regex_replace:"/[ö, ä, ü]/":"oe, ae, ue"
Many Greetings
Last edited by smarty-user on Tue Apr 08, 2014 2:31 pm; edited 1 time in total |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Apr 08, 2014 2:29 pm Post subject: |
|
|
no need for regex here.
Smarty 3:
|str_replace:[ö, ä, ü]:[oe, ae, ue]
Smarty 2 or 3:
|str_replace:$search:$replace
where $search and $replace are arrays. |
|
Back to top |
|
smarty-user Smarty Rookie
Joined: 08 Apr 2014 Posts: 5
|
Posted: Tue Apr 08, 2014 2:41 pm Post subject: |
|
|
The version is Smarty 3
|str_replace:[ö, ä, ü]:[oe, ae, ue]
if i use this appears a smaty error. Also with a single letter it dosen't work. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Apr 08, 2014 2:43 pm Post subject: |
|
|
oops, try this:
|str_replace:['ö','ä','ü']:['oe','ae','ue'] |
|
Back to top |
|
smarty-user Smarty Rookie
Joined: 08 Apr 2014 Posts: 5
|
Posted: Tue Apr 08, 2014 2:51 pm Post subject: |
|
|
|str_replace:['ö','ä','ü']:['oe','ae','ue']
So appears in the frontend only "Array" instead of the string. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Apr 08, 2014 2:56 pm Post subject: |
|
|
Ok I will ge this! lol. Try this:
Code: | |replace:['ö','ä','ü']:['oe','ae','ue'] |
I forget we have a wrapper to str_replace, as the order of params does not work directly. |
|
Back to top |
|
smarty-user Smarty Rookie
Joined: 08 Apr 2014 Posts: 5
|
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Apr 08, 2014 3:10 pm Post subject: |
|
|
It is working perfectly for me:
Code: | {"test öäü test"|replace:['ö','ä','ü']:['oe','ae','ue']} |
output:
|
|
Back to top |
|
smarty-user Smarty Rookie
Joined: 08 Apr 2014 Posts: 5
|
Posted: Tue Apr 08, 2014 3:33 pm Post subject: |
|
|
Thank you for the fast answers! Sorry, it was not the fault of Smarty that it not worked directly. Many Greetings |
|
Back to top |
|
|