namingpattern

package
v0.2.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2024 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidName

func IsValidName(n string) bool

NameIsValid returns true or false if the s match allowed HTML Name pattern. https://stackoverflow.com/questions/925994/what-characters-are-allowed-in-an-html-attribute-name. usefull to check attribute or token name.

returns FALSE if s is empty

must be trimed before, if required

func IsValidNameRune

func IsValidNameRune(r rune, first bool) bool

func IsValidStyleRune

func IsValidStyleRune(r rune) bool

func MakeValidName

func MakeValidName(n string) string

MakeValidName convert any invalid char in name into "_"

Example
fmt.Println(MakeValidName("john"))
fmt.Println(MakeValidName("john Doe"))
fmt.Println(MakeValidName("john>Doe_À"))
fmt.Println(MakeValidName("1john"))
Output:

john
john_Doe
john_Doe_À
_john

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL