From: Corey Jewett Date: 2007-07-06T14:52:47+09:00 Subject: Re: Regex: What does the ^ do? What is it called? On Jul 5, 2007, at 10:33 PM, Thomas Wieczorek wrote: > Hi > >> /^abc/ =~ "!abc" >> returns nil >> "You can use an anchor to match the beginning of a string" >> > > Just like the definition says ^ is used to mark the beginning of a > string: > /^abc/ =~ "abc!" > will return 0(the start of your pattern) > > >> /abc$/ =~ "abc!" >> returns nil >> "You can use an anchor to match the end of a string" > > $ is used to mark the end of a string: > /abc$/ =~ "!abc" > will return 0 again. > > /^I love Ruby$/ will only match the string "I love Ruby" and not "He > said: I love Ruby". /I love Ruby/ or /I love Ruby/$ will match /^I > love Ruby$/ > ^, $, \A, \Z, \B, etc. are called anchors. Corey