package notify

import (
	"regexp"
)

// isNumericString checks if a string contains only digits
func isNumericString(s string) bool {
	if s == "" {
		return false
	}
	for _, ch := range s {
		if ch < '0' || ch > '9' {
			return false
		}
	}
	return true
}

// extractNumberFromNamespace extracts a numeric string from namespace
// Example: "tidb1445428518469785" -> "1445428518469785"
func extractNumberFromNamespace(namespace string) string {
	re := regexp.MustCompile(`\d+`)
	matches := re.FindAllString(namespace, -1)
	if len(matches) > 0 {
		// Return the last (longest) numeric sequence
		return matches[len(matches)-1]
	}
	return ""
}
