Exact Match, How to find exact (whole only) match |
Exact Match, How to find exact (whole only) match |
Dag |
Apr 8 2020, 06:27 AM
Post
#1
|
Advanced Member Group: Members Posts: 107 Joined: 24-October 06 Member No.: 549 |
I need to find and replace strings inside the text. In this case, text is in the array format. I don't want to replace parts of the string if full string do not match. Samples:
CODE $find = array('Dominican Republic','Netherlands Antilles','Netherlands','Republic'); $replace = array('Доминиканская Республика','Нидерландские Антильские острова','Нидерланды','Република'); $text = array('Netherlands','Caribbean Netherlands','Republic','Dominican Republic','Netherlands Antilles','My Personal Republic'); $textNew = str_replace($find,$replace,$text); Result is CODE Array ( [0] => Нидерланды [1] => Caribbean Нидерланды [2] => Република [3] => Доминиканская Республика [4] => Нидерландские Антильские острова [5] => My Personal Република ) Walking through string by string... here is one string only: CODE $text = array('Caribbean Netherlands'); Result is CODE Array ( [0] => Caribbean Нидерланды ) Regexp "/b" didn't help. Any ides about this? Is it well known issue and is it very simple to be solved? Thanks in advance. |
Lo-Fi Version | Time is now: 6th May 2024 - 09:22 PM |