11.17. Anchors

^            # at the beginning of the pattern means beginning of the string
$            # at the end of the pattern means the end of the string

/the/        # matches anywhere in the string:             "atheneum", "thermostat", "the", "mathe"
/^the/       # matches only if the string starts with the  "thermostat", "the"
/the$/       # matches only if the string ends with the    "the", "mathe"
/^the$/      # matches only if the string                  "the"

/^\s*$/      # the string contains only white spaces (it looks like an empty string)


\b           # Word delimiter
/\bstruct\b/ # match every place the word "struct" but not "structure" or "construct"
/\b\w+\b/    # A single "word"

If you are interested in on-site trainings by the author, please contact me directly.

Online courses:

Would you like to get
updated when I publish
the next article?

Follow me:

Google Plus Twitter RSS feed