Hi
I trying do something like that:
I’ve got some string – 'Hello World!' for example.
And I want replace all character in it except the first one and white spaces.
so… result will be: "H.... ......";
I don’t want delete it, just replacing with "." or other character.
I tried doing this with preg_replace but with no results.
You can do it like so:
It works by ensuring that we aren’t at the beginning of the string with a negative lookahead for the start of string anchor, then matches a non-whitespace character using the negated whitespace character class.