A colinha de hoje mostra como pegar o começo de uma string tanto em Go como em Python sem usar expressões regulares 🎉
Vamos supor que você tem a seguinte string: "Gopher" e você quer saber se ela começa com "Go" e também se começa com "C". Em Go:
class="highlight">
1
2
3
4
5
6
7
8
9
10
11
package main
import (
"fmt"
"strings"
)
func main() {
fmt.Println(strings.HasPrefix("Gopher", "Go"))
fmt.Println(strings.HasPrefix("Gopher", "C"))
}
e em Python:
class="highlight">