• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 20. The RegExp Object: Working w... > Regular Expressions: Assertions

Regular Expressions: Assertions

You use regular expression assertions (sometimes called anchors) to match a condition in some text, not actual text. For example, the ^ assertion matches the beginning of a line, as we’ve already seen. Assertions are “zero-width,” which means they do not extend the matched string at all. (In other words, you’re matching a condition in the text, not specific characters.) Here are the possible assertions, some of which we’ve already seen:

  • ^ Match the beginning of the line

  • $ Match the end of the line (or before newline at the end)

  • \b Match a word boundary

  • \B Match a non-word boundary


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint