[go-nuts] Re: regexp group multi Replace Pattern

2020-09-03 Thread 'Emilius Omeen' via golang-nuts
thank you четверг, 3 сентября 2020 г., 13:13:59 UTC+3 пользователь Brian Candler написал: > > On Thursday, 3 September 2020 10:15:29 UTC+1, Emilius Omeen wrote: >> >> pkg "regexp" not have function which allow many group replace, only have >> ReplaceAllString >> >> >> > If I just take the examp

[go-nuts] Re: regexp group multi Replace Pattern

2020-09-03 Thread Brian Candler
On Thursday, 3 September 2020 10:15:29 UTC+1, Emilius Omeen wrote: > > pkg "regexp" not have function which allow many group replace, only have > ReplaceAllString > > > If I just take the examples you posted at the start, I can do that with a single ReplaceAllString: https://play.golang.org/p/9h

[go-nuts] Re: regexp group multi Replace Pattern

2020-09-03 Thread 'Emilius Omeen' via golang-nuts
pkg "regexp" not have function which allow many group replace, only have ReplaceAllString // ReplaceAllString returns a copy of src, replacing matches of the Regexp // with the replacement string repl. Inside repl, $ signs are interpreted as // in Expand, so for instance $1 represents the t

[go-nuts] Re: regexp group multi Replace Pattern

2020-09-02 Thread Amnon
There are various projects that combine multiple regexps into a single DFA. Have a look at https://github.com/proebsting/re On Wednesday, 2 September 2020 21:23:40 UTC+1, Brian Candler wrote: > > Can you define the problem more clearly? > > It looks like you just want to replace a leading "9", "00

[go-nuts] Re: regexp group multi Replace Pattern

2020-09-02 Thread Brian Candler
Can you define the problem more clearly? It looks like you just want to replace a leading "9", "001" or "+1" with "1"? In that case, you just match ^(9|001|[+]1) and replace it with 1 If that's not what you want, then what are the exact rules for how the input needs to be changed? -- You rec