Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Restricting string length #657

Answered by mpvl
khepin asked this question in Q&A
Jan 22, 2021 · 3 comments · 2 replies
Discussion options

You must be logged in to vote
import "strings"

v: strings.MaxRunes(8) & strings.MinRunes(8)

There is a PR pending to add NumRunes too.

But you could make regex's variable:

#StrLen: {
    =~"^.{\(#n)}$"
   #n: int
}
#StrLen8: { #StrLen, #n: 8 }

Scalar values may have definition fields associated with them. This is a fairly new feature and some syntax has been proposed to make this more natural.

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by khepin
Comment options

You must be logged in to vote
2 replies
@khepin
Comment options

@extemporalgenome
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants