Truncate uid
truncate_uid
#
Functions:
Name | Description |
---|---|
truncate_uid |
Truncate the UID to the last n characters (including periods and underscores). |
truncate_uid
#
truncate_uid(uid: str, last_digits: int = 5) -> str
Truncate the UID to the last n characters (including periods and underscores).
If the UID is shorter than last_digits
, the entire UID is returned.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
str
|
The UID string to truncate. |
required |
|
int
|
The number of characters to keep at the end of the UID (default is 5). |
5
|
Returns:
Type | Description |
---|---|
str
|
The truncated UID string. |
Examples:
>>> truncate_uid(
... "1.2.840.10008.1.2.1",
... last_digits=5,
... )
'.1.2.1'
>>> truncate_uid(
... "12345",
... last_digits=10,
... )
'12345'