Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "regexp"
- )
- var paragraph = `
- no me gusta esto px. yo odio toda la gente k piensan malo.
- no se pork quieren ser asi. todo bien son las que cosas.
- pero no se pq. px pq px pq px pq pork
- `
- func main() {
- var result string
- var mts int = 0
- r, _ := regexp.CompilePOSIX("p{1}[xq]")
- result = r.ReplaceAllString(paragraph, " porque ")
- matches := r.FindAllStringIndex(paragraph, 500)
- mts = mts + len(matches)
- r, _ = regexp.CompilePOSIX("pork")
- result = r.ReplaceAllString(result, " porque ")
- matches = r.FindAllStringIndex(paragraph, 500)
- mts = mts + len(matches)
- fmt.Println(result)
- fmt.Print(mts)
- fmt.Print(" matches in paragraph")
- }
Add Comment
Please, Sign In to add comment