Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. текст 123:123 текст 21.03.2019 текст текст текст текст текст
  2.  
  3. текст 123:123 текст (21.03.2019) текст текст текст текст текст
  4.  
  5. $str = 'текст 123:123 текст 21.03.2019 текст текст текст текст текст';
  6.  
  7. $str = preg_replace('~((?:d{2}.){2}d{4})~', '($1)', $str);
  8.  
  9. echo $str;
  10.  
  11. $content = 'текст 123:123 текст 21.03.2019 текст текст текст текст текст';
  12. $pattern = "/d{2}.d{2}.d{4}/";
  13.  
  14. if (preg_match($pattern, $content, $matches)) {
  15. echo str_replace($matches[0], '('.$matches[0].')', $content);
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement