@kjk1/

book strings replace regex

Go

No description

fork
loading
Files
  • main.go

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.8695729015811702","path":"main.go","file":{"path":"main.go","content":{"asEncoding":{"base64":"cGFja2FnZSBtYWluCgppbXBvcnQgKAoJImZtdCIKCSJyZWdleHAiCikKCmZ1bmMgbWFpbigpIHsKCS8vIDpzaG93IHN0YXJ0CglzIDo9ICJvcmlnaW5hbCBzdHJpbmcgb3JpZ2luYWwiCglyeCA6PSByZWdleHAuTXVzdENvbXBpbGUoIig/VSlvci4qYWwiKQoJczIgOj0gcnguUmVwbGFjZUFsbFN0cmluZyhzLCAicmVwbGFjZWQiKQoJZm10LlByaW50ZigiczI6ICclcydcbiIsIHMyKQoJLy8gOnNob3cgZW5kCn0K"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package main

import (
	"fmt"
	"regexp"
)

func main() {
	// :show start
	s := "original string original"
	rx := regexp.MustCompile("(?U)or.*al")
	s2 := rx.ReplaceAllString(s, "replaced")
	fmt.Printf("s2: '%s'\n", s2)
	// :show end
}