Sozun sonu ve ya baslangici PHP regular ifadelerinde

\b komanda sozun baslangicini ve ya sonunu bildirir, \B ise muqayisede - sozun baslangici ve ya sonu olmayan yeri. Soz deyende ne basa dusulur? Ilk baxisda bosluqlarla serhedlenen bir sey kimi gorunur, amma bu tam dogru deyil.

Asagidaki setre baxin: house with fence. 'with' altsetresi - bu bir sozdur (her iki terefinde bosluq var), lakin hem 'house', hem de 'fence' de sozdur, setrin basinda ve sonunda durur.

Gelin bu komandanin praktik tetbiqine baxaq.

Asagidaki numunede axtaris sablonu beledir: sozun baslangici, kicik latyn herfleri bir ve ya bir nece defe, sozun sonu. Belikle, regular ifade butun sozleri tapacaq ve onlari '!' ile evez edecek:

php<?php
  echo preg_replace('#\b[a-z]+\b#', '!', 'axx bxx xxx exx'); // '! ! ! !' cap edecek
?>
Задание 1

Setr verilmisdir:

php<?php
  $str = 'aaa xaa aaa xbb aaa';
?>

Regular ifade yazin, hansi ki, setrleri sablona uygun tapacaq: sozun baslangicinda 'x' herfi.