       endPattern = new Pattern(@grammar, { match: end, captures: endCaptures ? captures, popRule: true})
       @pushRule = new Rule(@grammar, { @scopeName, patterns, endPattern })
     @anchored = @hasAnchor()
+
+  getRegex: (firstLine, position, anchorPosition) ->
+    if @anchored
+      @replaceAnchor(firstLine, position, anchorPosition)
+    else
+      @regexSource
 
   hasAnchor: ->
     return false unless @regexSource

  getScanner: (ruleStack, baseGrammar, position, firstLine) ->
    return scanner if scanner = @scannersByBaseGrammarName[baseGrammar.name]

    anchored = false
    injected = false
    regexes = []
    patterns = @getIncludedPatterns(baseGrammar)
    scopes = scopesFromStack(ruleStack)
    for injection in @injections

        patterns.push(injection.patterns...)
        injected = true

    anchored = false
    regexes = _.map patterns, (pattern) =>
      anchored = true if pattern.anchored
      pattern.getRegex(firstLine, position, @anchorPosition)

    regexScanner = new OnigScanner(regexes)
    regexScanner.patterns = patterns
