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.

Build modern and responsive webpages


Build modern and responsive webpages Try Front-end

This book teaches HTML as if it's for anyone - hobbyists, students, and professionals - and it's full-color throughout. It utilizes information graphics and lifestyle photography to explain the topics in a simple way that is engaging. You can progress through the chapters from beginning to end or just dip into topics of particular interest at your leisure.

$ Check price
29.9929.99Amazon 4.5 logo(926+ reviews)

More Front-end resources

Take your Linux skills to the next level!

How Linux Works

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

In this completely revised second edition of the perennial best seller How Linux Works, author Brian Ward makes the concepts behind Linux internals accessible to anyone curious about the inner workings of the operating system. Inside, you'll find the kind of knowledge that normally comes from years of experience doing things the hard way.

$ Check price
39.9539.95Amazon 5 logo(114+ reviews)

More Linux & UNIX resources