It is necessary to replace all the encountered points except for such cases:

рис. г. табл. 

I do this:

 #([^\sрис.\s][^\sг.\s][^\sтабл.\s][.])#u 

As a result, they are not replaced except for the necessary combinations of ri. that abl
And so on.
How to make [^ \ sris. \ S] cover exactly the combinations of characters in fig.
not ri. is
The \ w + modifier does not seem to help or I don’t know where to put it.

  • one
    round brackets. not square - rjhdby

1 answer 1

For clarity, all the necessary points will be replaced with a dash "-":

 $str = 'Нужно.заменить..все...встречающиеся. точки .кроме таких случаев: рис. г. табл.'; $str = preg_replace('~(?<!рис|г|табл)\.~', '-', $str); var_dump($str); 

Result:

 Нужно-заменить--все---встречающиеся- точки -кроме таких случаев: рис. г. табл. 
  • Thank you so much! - Alexander
  • @ Alexander If my answer is the solution to your question, tick it off. - Edward