Reputation: 29507
Recently I downloaded a source (LevBot) and then I see this line:
} elsif($text =~ /^slaps $levbot_nick/i) {
/^
and /i
do?I think this is regular expression, I'm right?
Upvotes: 1
Views: 15280
Reputation: 1
^(carat) symbol denotes regex 'starting with'. Here the pattern should start with slaps.
/i denotes case insensitive search
To match pattern
Yes, you are right. It is regular expression.
In your case matching pattern is starting with slaps along with value in levbot_nick variable.
Upvotes: 0
Reputation: 17510
This syntax in Perl was inspired by awk's /xxx/ Pattern matching feature.
Upvotes: 0
Reputation: 59461
/
Delimiter denoting start of regex (The char /
is not part of the regex)^
Matches the start of a line /
Delimiter for the end of the regex (not part of the regex)i
Flag to make the regex case insensitiveOther flags possible are:
g
Global s
Dot matches new line charactersx
Extended - ignores whitespaces in the pattern and allows commentsm
Multiline mode.Upvotes: 26
Reputation: 8966
/^
matches the beginning of a line.
/i
means case insensitive search.
Upvotes: 3
Reputation: 110499
Yes, this is a regular expression.
/
on either side mark the pattern's beginning and end.^
at the start of the patten means "only match this at the beginning of the string, and nowhere else."i
after the end of the pattern is a modifier, it means "be case-insensitive when matching this", since the default is case-sensitive.Upvotes: 4
Reputation: 123881
Thats a regular expression
/^slaps $levbot_nick/i
/^ means starts with (actually ^ alone)
/i means ignore case (i alone after / /)
first and last / slashes are boundary of regex
Upvotes: 3
Reputation: 272347
Yes. See the perlre documentation. Briefly, /^
matches the start of a line, and /i
means it's case-insensitive.
Upvotes: 3