is_w3c_prefix
- is_w3c_prefix(prefix: str) bool [source]
Return if the string is a valid prefix under the W3C specification.
- Parameters:
prefix – A string
- Returns:
If the string is a valid prefix under the W3C specification.
Validation is implemented as a regular expression match against
curies.w3c.NCNAME_PATTERN
, as defined by the W3C here.Examples
Strings containig numbers, letters, and underscores are valid prefixes.
>>> is_w3c_prefix("GO") True
The W3C specification states that the prefix ‘_’ is reserved for use by languages that support RDF. For this reason, the prefix ‘_’ SHOULD be avoided by authors.
>>> is_w3c_prefix("_") True
Strings starting with a number are not valid prefixes.
>>> is_w3c_prefix("3dmet")
Strings containing a colon or other characters are invalid
>>> is_w3c_prefix("GO:") False