Skip to content
mck89 edited this page Mar 18, 2015 · 1 revision

Anchors

Circumflex (^) and dollar ($) in a regexp outside a character class, anchor the regex respectively to the start and to the end of the subject (or the line if multiline mode is enabled).

In REBuilder you can anchor containers using setStartAnchored and setEndAnchored methods that take a boolean that indicates if the container must be anchored. For example:

$regex
      ->setStartAnchored(true)
      ->setEndAnchored(true)
      ->addChar("abc");
echo $regex; // "/^abc$/"

Note that not all the containers can be anchored, if you want to check if the container can be anchored you can use the supportsAnchors method.

Clone this wiki locally