Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Regex Anchors confusion

by merlyn (Sage)
on May 18, 2005 at 14:21 UTC ( [id://458224] : note . print w/replies, xml ) Need Help??


in reply to Regex Anchors confusion

An anchor has no width: it's an assertion of a condition required for a successful match. For /^/ to be true, we must be at the beginning of a string, and so on. You can certainly have two anchors next to each other, provided both conditions are true. For example, to check that the beginning of the string is not also a word boundary (meaning the string starts with \W or is empty), we can use /^\B/.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.