Reputation: 2032
I'm trying to accomplish the following:
search for a lowercase letter followed by uppercase letter. replace this with the lowercase letter, followed by '. ', followed by the uppercase letter.
example:
helloAre you there
should become:
hello. Are you there
Upvotes: 2
Views: 186
Reputation: 27913
Inserts a dot-space .
between the lower and upper-case letters.
preg_replace('/(?<=[a-z])(?=[A-Z])/', '. ', $str);
To prevent iP
, use this:
preg_replace('/(?!iP)([a-z])(?=[A-Z])/', '$1. ', $str);
Upvotes: 3
Reputation: 17356
If $text
is the original text you could use
$text = preg_replace('/([a-z])([A-Z])/', '\1. \2', $text);
Upvotes: 0