1

我試圖從電子郵件中將我的銀行餘額號提取到Google Spreadsheets中。到目前爲止,我有一個Google腳本抓取電子郵件,然後以rawcontent形式將其粘貼到Google電子表格中。您可以在下面看到正在粘貼的RawContent。 (這不是我的銀行存款餘額或卡那就是已經使用並採取了我的銀行網站的電子郵件會是什麼樣草案的模板。在單元格中搜索術語

MIME-Version: 1.0 
    Received: by 10.79.112.196 with HTTP; Tue, 20 Oct 2015 18:13:30 -0700 (PDT) 
    Date: Wed, 21 Oct 2015 02:13:30 +0100 
    Delivered-To: [email protected] 
    Message-ID: <CAL9nrMo3OXzMsPUMpXjOO1AEg_u72czoYLEQLeWz [email protected]> 
    Subject: BB TEST 
    From: Liam Nagle <[email protected]> 
    To: Liam Nagle <[email protected]> 
    Content-Type: multipart/alternative; boundary=001a114d944e1c2fac052293164b 

    --001a114d944e1c2fac052293164b 
    Content-Type: text/plain; charset=UTF-8 
    Content-Transfer-Encoding: quoted-printable 

    Dear Mr. Broe, 

    Your weekly account summary for 
    account ending 6920 is below: 

    Current Balance as at 12:30 26 Sep: 
    =C2=A32500.00+ 
    Available Balance as at 12:30 26 Sep: 
    =C2=A32700.00+ 

    RECENT TRANSACTIONS: 
    25Sep Transfer =C2=A310.59- 
    25Sep Cheque deposit 150.00+ 
    24Sep Direct Debit =C2=A33.60- 
    23Sep Standing order =C2=A323.50- 
    21Sep CC payment =C2=A349.00- 

    Regards, 

    Santander Alerts 

    --001a114d944e1c2fac052293164b 
    Content-Type: text/html; charset=UTF-8 
    Content-Transfer-Encoding: quoted-printable 

    <div dir=3D"ltr"><span style=3D"color:rgb(102,102,102);font-family:Verdana,= 
    Arial,Helvetica,sans-serif;font-size:11.04px;letter-spacing:-0.1104px;line-= 
    height:17.9952px">Dear Mr. Broe,</span><br style=3D"margin:0px;color:rgb(10= 
    2,102,102);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11.04px= 
    ;letter-spacing:-0.1104px;line-height:17.9952px"><br style=3D"margin:0px;co= 
    lor:rgb(102,102,102);font-family:Verdana,Arial,Helvetica,sans-serif;font-si= 
    ze:11.04px;letter-spacing:-0.1104px;line-height:17.9952px"><span style=3D"c= 
    olor:rgb(102,102,102);font-family:Verdana,Arial,Helvetica,sans-serif;font-s= 
    ize:11.04px;letter-spacing:-0.1104px;line-height:17.9952px">Your weekly acc= 
    ount summary for</span><br style=3D"margin:0px;color:rgb(102,102,102);font-= 
    family:Verdana,Arial,Helvetica,sans-serif;font-size:11.04px;letter-spacing:= 
    -0.1104px;line-height:17.9952px"><span style=3D"color:rgb(102,102,102);font= 
    -family:Verdana,Arial,Helvetica,sans-serif;font-size:11.04px;letter-spacing= 
    :-0.1104px;line-height:17.9952px">account ending 6920 is below:</span><br s= 
    tyle=3D"margin:0px;color:rgb(102,102,102);font-family:Verdana,Arial,Helveti= 
    ca,sans-serif;font-size:11.04px;letter-spacing:-0.1104px;line-height:17.995= 
    2px"><br style=3D"margin:0px;color:rgb(102,102,102);font-family:Verdana,Ari= 
    al,Helvetica,sans-serif;font-size:11.04px;letter-spacing:-0.1104px;line-hei= 
    ght:17.9952px"><span style=3D"color:rgb(102,102,102);font-family:Verdana,Ar= 
    ial,Helvetica,sans-serif;font-size:11.04px;letter-spacing:-0.1104px;line-he= 
    ight:17.9952px">Current Balance as at 12:30 26 Sep:=C2=A0</span><br style= 
    =3D"margin:0px;color:rgb(102,102,102);font-family:Verdana,Arial,Helvetica,s= 
    ans-serif;font-size:11.04px;letter-spacing:-0.1104px;line-height:17.9952px"= 
    ><span style=3D"color:rgb(102,102,102);font-family:Verdana,Arial,Helvetica,= 
    sans-serif;font-size:11.04px;letter-spacing:-0.1104px;line-height:17.9952px= 
    ">=C2=A32500.00+</span><br style=3D"margin:0px;color:rgb(102,102,102);font-= 
    family:Verdana,Arial,Helvetica,sans-serif;font-size:11.04px;letter-spacing:= 
    -0.1104px;line-height:17.9952px"><span style=3D"color:rgb(102,102,102);font= 
    -family:Verdana,Arial,Helvetica,sans-serif;font-size:11.04px;letter-spacing= 
    :-0.1104px;line-height:17.9952px">Available Balance as at 12:30 26 Sep:=C2= 
    =A0</span><br style=3D"margin:0px;color:rgb(102,102,102);font-family:Verdan= 
    a,Arial,Helvetica,sans-serif;font-size:11.04px;letter-spacing:-0.1104px;lin= 
    e-height:17.9952px"><span style=3D"color:rgb(102,102,102);font-family:Verda= 
    na,Arial,Helvetica,sans-serif;font-size:11.04px;letter-spacing:-0.1104px;li= 
    ne-height:17.9952px">=C2=A32700.00+</span><br style=3D"margin:0px;color:rgb= 
    (102,102,102);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11.0= 
    4px;letter-spacing:-0.1104px;line-height:17.9952px"><br style=3D"margin:0px= 
    ;color:rgb(102,102,102);font-family:Verdana,Arial,Helvetica,sans-serif;font= 
    -size:11.04px;letter-spacing:-0.1104px;line-height:17.9952px"><span style= 
    =3D"color:rgb(102,102,102);font-family:Verdana,Arial,Helvetica,sans-serif;f= 
    ont-size:11.04px;letter-spacing:-0.1104px;line-height:17.9952px">RECENT TRA= 
    NSACTIONS:</span><br style=3D"margin:0px;color:rgb(102,102,102);font-family= 
    :Verdana,Arial,Helvetica,sans-serif;font-size:11.04px;letter-spacing:-0.110= 
    4px;line-height:17.9952px"><span style=3D"color:rgb(102,102,102);font-famil= 
    y:Verdana,Arial,Helvetica,sans-serif;font-size:11.04px;letter-spacing:-0.11= 
    04px;line-height:17.9952px">25Sep Transfer =C2=A310.59-</span><br style=3D"= 
    margin:0px;color:rgb(102,102,102);font-family:Verdana,Arial,Helvetica,sans-= 
    serif;font-size:11.04px;letter-spacing:-0.1104px;line-height:17.9952px"><sp= 
    an style=3D"color:rgb(102,102,102);font-family:Verdana,Arial,Helvetica,sans= 
    -serif;font-size:11.04px;letter-spacing:-0.1104px;line-height:17.9952px">25= 
    Sep Cheque deposit 150.00+</span><br style=3D"margin:0px;color:rgb(102,102,= 
    102);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11.04px;lette= 
    r-spacing:-0.1104px;line-height:17.9952px"><span style=3D"color:rgb(102,102= 
    ,102);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11.04px;lett= 
    er-spacing:-0.1104px;line-height:17.9952px">24Sep Direct Debit =C2=A33.60-<= 
    /span><br style=3D"margin:0px;color:rgb(102,102,102);font-family:Verdana,Ar= 
    ial,Helvetica,sans-serif;font-size:11.04px;letter-spacing:-0.1104px;line-he= 
    ight:17.9952px"><span style=3D"color:rgb(102,102,102);font-family:Verdana,A= 
    rial,Helvetica,sans-serif;font-size:11.04px;letter-spacing:-0.1104px;line-h= 
    eight:17.9952px">23Sep Standing order =C2=A323.50-</span><br style=3D"margi= 
    n:0px;color:rgb(102,102,102);font-family:Verdana,Arial,Helvetica,sans-serif= 
    ;font-size:11.04px;letter-spacing:-0.1104px;line-height:17.9952px"><span st= 
    yle=3D"color:rgb(102,102,102);font-family:Verdana,Arial,Helvetica,sans-seri= 
    f;font-size:11.04px;letter-spacing:-0.1104px;line-height:17.9952px">21Sep C= 
    C payment =C2=A349.00-</span><br style=3D"margin:0px;color:rgb(102,102,102)= 
    ;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11.04px;letter-sp= 
    acing:-0.1104px;line-height:17.9952px"><br style=3D"margin:0px;color:rgb(10= 
    2,102,102);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11.04px= 
    ;letter-spacing:-0.1104px;line-height:17.9952px"><span style=3D"color:rgb(1= 
    02,102,102);font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11.04p= 
    x;letter-spacing:-0.1104px;line-height:17.9952px">Regards,</span><br style= 
    =3D"margin:0px;color:rgb(102,102,102);font-family:Verdana,Arial,Helvetica,s= 
    ans-serif;font-size:11.04px;letter-spacing:-0.1104px;line-height:17.9952px"= 
    ><br style=3D"margin:0px;color:rgb(102,102,102);font-family:Verdana,Arial,H= 
    elvetica,sans-serif;font-size:11.04px;letter-spacing:-0.1104px;line-height:= 
    17.9952px"><span style=3D"color:rgb(102,102,102);font-family:Verdana,Arial,= 
    Helvetica,sans-serif;font-size:11.04px;letter-spacing:-0.1104px;line-height= 
    :17.9952px">Santander Alerts</span></div> 

    --001a114d944e1c2fac052293164b-- 

什麼,我希望能得到出這是它說:

Current Balance as at 12:30 26 Sep: 
    =C2=A32500.00+ 
    Available Balance as at 12:30 26 Sep: 
    =C2=A32700.00+ 

在這裏,我想提取數字2500.002700.00=C2=A3部分表示以RawContent形式編寫的£。另一個頁面上抽取兩個號碼我希望這些分配到兩個單元后,再使用這些數據來制定財務計劃等

+0

和它是不是一樣的編碼?似乎也喜歡它我也從我的專業知識 –

+0

嗯,我不知道這一點。我將刪除標籤。 –

+0

如何粘貼原始內容?這是全部在一個細胞中還是分散在多個細胞上? –

回答

1

您可以用公式來=REGEXEXTRACT(E4,"=C2=A3(\d+\.\d{2})\+")拿到第一場比賽,但第二個將是一個有點棘手。 由於您已經在使用腳本,我會編寫另一個快速函數來提取這些值。

function getBalance(){ 
    var data = SpreadsheetApp.getActiveSheet().getRange(1,1).getValue(); 
    var re = /=C2=A3(\d+\.\d{2})\+/g; 
    var results = [re.exec(data)[1], re.exec(data)[1]]; 
    return results; 
} 

這將讓文本,通過識別它們與原始£前綴提取兩個可用餘額和陣列中的歸還。

然後,您甚至可以從電子表格中運行=GETBALANCE(),它將爲您在兩個單獨的行中輸出餘額作爲輸出。

+0

我知道它與REGEXTRACT有關!只是無法讓我的頭在附近。我現在就測試一下! –

+0

完美的作品謝謝你! –

+0

如果這有助於您接受答案,以便將來人們可以輕鬆看到答案。謝謝 –