         # console.log('myIterator')
         myIterator = (obj) =>
             # console.log('iterating')
-            obj.replace(@formatTable(obj.matchText))
+            obj.replace(@formatTable(obj.match))
 
         for range in selectionsRanges
             # console.log(@regex)

class TableFormatter
    subscriptions: []
    #regex: /((.+?)\|)+?(.+)?\r?\n(([:\-\|]+?)\|)+?([:\-\|]+)?[ ]*(\r?\n((.+?)\|)+?(.+)?)+/mg
    regex: /((.+?)\|)+?(.+)?\r?\n(([\s:\-\|]+?)\|)+?([\s:\-\|]+)?[ ]*(\r?\n((.+?)\|)+?(.+)?)+/mg
                            
    constructor: ->
        atom.workspace.observeTextEditors (editor) =>
            subscription = editor.getBuffer().onWillSave =>

            else
                return string

        formatline = text[2].trim()
        headerline = text[1].trim()

        if headerline.length==0
            formatrow=0
            lines = text[3].trim().split('\n')
        else
            formatrow=1
            lines = (text[1]+text[3]).trim().split('\n')
        rows = lines.length

        formatline = formatline.trim().replace(/(^\||\|$)/g,"")
        fstrings = formatline.split('|')
        justify = []
        for cell in fstrings
            cell=cell.trim()
            ends = cell[0] + (cell[cell.length-1] || '')
            if ends == '::'
                justify.push('::')
