I have a string
centenary
I'd like to match ten
only when it is not preceded by cen
.
So far I have this regex:
(([^c][^e][^n])|^)ten
That returns true
in the following cases tenary
, blahtenary
and false for ctenary
, cetenary
, centanary
package main
import (
"fmt"
"regexp"
)
func main() {
txt := "ctenary"
rx := `(([^c][^e][^n])|^)ten`
re := regexp.MustCompile(rx)
m := re.MatchString(txt)
fmt.Println(m)
}