04. Anchors begins and ends with

In some cases, you'll need to specify that a string starts and/or ends with certain characters. For example, if you were reading from an ouput, and had to match if it reads "success", you couldn't just write a regex that matches "success", as "not success" and "success did not occur" would also be valid matches.

Begins and Ends with

To specify that a string should strictly start or end with certain character, we can use the hat (^) or dollar sign ($).

Match all strings that start with zip.
Match all strings that end with zip.
Match all strings that start with z, has any two characters then an i, then another character, and ends with p.

Take your Linux skills to the next level!

Command Line Kung Fu

Take your Linux skills to the next level! Try Linux & UNIX

Command Line Kung Fu is packed with dozens of tips and practical real-world examples. You won't find theoretical examples in this book. The examples demonstrate how to solve actual problems. The tactics are easy to find, too. Each chapter covers a specific topic and groups related tips and examples together.

$ Check price
14.9914.99Amazon 4.5 logo(27+ reviews)

More Linux & UNIX resources

Build modern and responsive webpages

The Modern Web

Build modern and responsive webpages Try Front-end

The Modern Web will guide you through the most important tools of device-agnostic web development, including HTML5, CSS3, and JavaScript. The plain-english explanations and practical examples emphasize the techniques, principles, and practices that you'll need to easily transcend individual browser quirks and stay relevant as these technologies are updated.

$ Check price
34.9534.95Amazon 4.5 logo(30+ reviews)

More Front-end resources