Skip to content
Advertisement

How to give space in sentence in string with preg_replace?

Here’s i have an issue : sentence : “12223233 sekamar berempat”

JavaScript

result: sekamarberempat

expectation: sekamar berempat

thank you

Advertisement

Answer

You can replace all chars other than lowercase letters with a space and trim the string:

JavaScript

See the PHP demo.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement