Canister id regex

Needless to say, regex isn’t one of my strength. So, anyone has a better regex that the one I came with to validate the format of a canister id?


This is quite good and specific. You could also use (\w{5}-){4}\w{3}, however it is less specific, since \w also includes underscore.

1 Like

Ah nice, that could be handy for a shorter version. Thanks for the share and feedback

1 Like

The long version, but simple.

1 Like

I included upper case because the Interface Spec says:

The textual representation is conventionally printed with lower case letters, but parsed case-insensitively.


Thanks for the hint about lower and upper case, did not knew!

The long but simple version of the regex is also neat.

1 Like