D
D
devastation_kvlt2016-04-11 17:05:39
PHP
devastation_kvlt, 2016-04-11 17:05:39

How to get rid of eating a character?

There is a regular .
Need : find a dot after which there is a non - space character and replace the dot with a dot with a space .
Example : "Offer.Second offer" to "Offer.Second offer".
Problem : replaces a dot with a non-whitespace character with a dot with a space :
"Sentence. second sentence"
Question : how to write a regular expression so that it does not store the character being checked?
All code , just in case

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey, 2016-04-11
@devastation_kvlt

echo(preg_replace('/(\.)(\S)/', '$1 $2', $s));
and even better
echo(preg_replace('/\s*(\.)(\S)/', '$1 $2', $s));

O
OVK2015, 2016-04-11
@OVK2015

$testStr = "Предложение.Второе предложение";
$regExpWrapper = "#\.(?=\S)#si";
$testStr = preg_replace($regExpWrapper, ". ", $testStr);
echo $testStr;

Will it go?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question