Tutorial by Examples

When multi-line (?m) modifier is turned off, ^ matches only the input string's beginning: For the regex ^He The following input strings match: Hedgehog\nFirst line\nLast line Help me, please He And the following input strings do not match: First line\nHedgehog\nLast line IHedgehog ...
If you need to use the ^ character in a character class (Character classes ), either put it somewhere other than the beginning of the class: [12^3] Or escape the ^ using a backslash \: [\^123] If you want to match the caret character itself outside a character class, you need to escape it: ...
While many people think that ^ means the start of a string, it actually means start of a line. For an actual start of string anchor use, \A. The string hello\nworld (or more clearly) hello world Would be matched by the regular expressions ^h, ^w and \Ah but not by \Aw
By default, the caret ^ metacharacter matches the position before the first character in the string. Given the string "charsequence" applied against the following patterns: /^char/ & /^sequence/, the engine will try to match as follows: /^char/ ^ - charsequence c - charsequ...

Page 1 of 1