Created
June 1, 2020 03:18
-
-
Save bergpb/29a762c821e7b28efea98555dc25f1fb to your computer and use it in GitHub Desktop.
Example to parse a string with Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"strings" | |
) | |
var data string = `<p>O dólar hoje tá R$ 5,40<br/>O Bitcoin hoje tá R$ 51347,38</p><p></p><p>O dólar australiano hoje tá R$ 3,57<br/>O dólar canadense hoje tá R$ 3,92<br/>O dólar neozelandês hoje tá R$ 3,42<br/>O euro hoje tá R$ 5,98<br/>O franco suíço hoje tá R$ 5,60<br/>O real hoje tá 19,90 ienes<br/>A libra hoje tá R$ 6,66<br/>O novo sol hoje tá R$ 1,57<br/>O grama do ouro hoje tá R$ 295,83<br/>O peso argentino hoje tá R$ 0,07<br/>O real hoje tá 149,54 pesos chilenos<br/>O peso mexicano hoje tá R$ 0,17<br/>O peso uruguaio tá R$ 0,11<br/>O rublo russo hoje tá R$ 0,07<br/>O won sul-coreano hoje tá R$ 0,004366<br/>O yuan hoje tá R$ 0,75</p><p></p><p>O dólar turismo hoje tá R$ 5,59<br/>O euro turismo hoje tá R$ 6,22</p><p></p><p>O Aeternity hoje tá R$ 0,68<br/>A ARK hoje tá R$ 1,15<br/>O Basic Attention Token hoje tá R$ 1,12<br/>O Bitcoin Cash hoje tá R$ 1280,50<br/>O Bitcoin Diamond hoje tá R$ 3,05<br/>O Bitcoin Gold hoje tá R$ 49,13<br/>O Bitcoin SV hoje tá R$ 1020,21<br/>A BitShares hoje tá R$ 0,12<br/>O Bytecoin hoje tá R$ 0,001348<br/>A Bytom hoje tá R$ 0,36<br/>O Cardano hoje tá R$ 0,33<br/>O Dash hoje tá R$ 398,33<br/>A Decred hoje tá R$ 78,30<br/>A Dentacoin hoje tá R$ 0,000027<br/>A DigiByte hoje tá R$ 0,09<br/>O Dogecoin hoje tá R$ 0,013586<br/>A Electroneum hoje tá R$ 0,04<br/>O EOS hoje tá R$ 14,08<br/>O Ethereum hoje tá R$ 1197,87<br/>O Ethereum Classic hoje tá R$ 37,98<br/>O Golem hoje tá R$ 0,27<br/>O Icon hoje tá R$ 1,91<br/>A Iota hoje tá R$ 1,06<br/>A Komodo hoje tá R$ 3,21<br/>A Lisk hoje tá R$ 6,42<br/>O Litecoin hoje tá R$ 243,88<br/>O Monero hoje tá R$ 358,49<br/>A Nano hoje tá R$ 4,86<br/>A NEM hoje tá R$ 0,22<br/>O NEO hoje tá R$ 54,68<br/>O OmiseGO hoje tá R$ 8,68<br/>A Ontology hoje tá R$ 2,77<br/>A Pundi X hoje tá R$ 0,000772<br/>A Populous hoje tá R$ 1,73<br/>O Qtum Lumens hoje tá R$ 8,98<br/>O ReddCoin hoje tá R$ 0,007931<br/>A SALT hoje tá R$ 0,39<br/>A Siacoin hoje tá R$ 0,012689<br/>A Status hoje tá R$ 0,14<br/>A Steem hoje tá R$ 1,11<br/>O Stellar Lumens hoje tá R$ 0,36<br/>A Stratis hoje tá R$ 1,76<br/>A Tezos hoje tá R$ 15,37<br/>O Tether hoje tá R$ 5,39<br/>O TRON hoje tá R$ 0,08<br/>A TrueUSD hoje tá R$ 5,39<br/>A USD Coin hoje tá R$ 5,40<br/>A VeChain hoje tá R$ 0,02<br/>O Verge hoje tá R$ 0,02<br/>A Wanchain hoje tá R$ 0,99<br/>A Waves hoje tá R$ 5,83<br/>O XRP hoje tá R$ 1,08<br/>O Zcash hoje tá R$ 251,41<br/>A Zilliqa hoje tá R$ 0,06<br/>O 0x hoje tá R$ 1,80</p><p></p><p>@ <a href="https://DolarHoje.com">DolarHoje.com</a></p>` | |
func main() { | |
data_ := strings.TrimLeft(data, "<p>") | |
data0 := strings.ReplaceAll(data_, "</p><p></p><p>", "</br>") | |
data1 := strings.ReplaceAll(data0, "</br>", "<br/>") | |
data2 := strings.Split(data1, "@") | |
formated_data := strings.Split(data2[0], "<br/>") | |
for _, num := range formated_data { | |
fmt.Println(num) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment