Skip to main content

String Utilities

String utilities in Python.

PyPI PyPI - Python Version PyPI - License PyPI - Downloads PyPI - Downloads Coverage Status GitHub code size in bytes GitHub last commit DeepSource

StringUtil class

Methods

Method Description Parameters Returns
decode_base64 Decodes a base64 encoded string. encoded_text (str) The base64 encoded string to decode. str The decoded string.
encode_base64 Encodes a string to base64. text (str) The string to encode. str The base64 encoded string.
get_char_and_ascii_number_pairs Returns a list of tuples containing the character and its ASCII number. text (str) The string to analyze. list[tuple[str, int]] A list of tuples containing the character and its ASCII number.
get_emails Returns a list of email addresses found in a string. text (str) The string to search for email addresses. list[str] A list of email addresses found in the string (without duplications).
get_last_char Returns the last character of a string. text (str) The string to analyze. str The last character of the string.
get_urls Returns a list of URLs found in a string. text (str) The string to search for URLs. list[str] A list of URLs found in the string (without duplications).
is_decimal Checks if a string is a decimal number. text (Optional[str]) The string to check. bool True if the string is a decimal number, False otherwise.
is_int Checks if a string is an integer. text (Optional[str]) The string to check. bool True if the string is an integer, False otherwise.
is_json Checks if a string is a valid JSON. text (Optional[str]) The string to check. bool True if the string is a valid JSON, False otherwise.
is_positive_decimal Checks if a string is a positive decimal number. text (Optional[str]) The string to check. bool True if the string is a positive decimal number, False otherwise.
is_positive_int Checks if a string is a positive integer. text (Optional[str]) The string to check. bool True if the string is a positive integer, False otherwise.
is_unsigned_decimal Checks if a string is an unsigned decimal number. text (Optional[str]) The string to check. bool True if the string is an unsigned decimal number, False otherwise.
is_unsigned_int Checks if a string is an unsigned integer. text (Optional[str]) The string to check. bool True if the string is an unsigned integer, False otherwise.
remove_extra_spaces Removes extra spaces from a string. text (str) The string to process.
is_remove_end_of_line (bool, Default: False) If set to True, the function will treat newline characters (e.g., \n, \r) as extra spaces and remove them, effectively joining all lines into a single continuous line of text`
str A text without extra spaces
replace Multiple string replacement. text (str) The original string.
replacements (dict[str, str]) A dictionary where keys are substrings to be replaced and values are their replacements.
str The modified string after replacements.
sub_string Returns a substring from a string. text (str) The string to extract the substring from.
start_delimiter (str) Sub string start delimiter.
end_delimiter (Optional[str]) Sub string end delimiter.
str The extracted substring.
sub_string_list Returns a list of substrings from a string. text (str) The string to extract the substrings from.
start_delimiter (str) Sub string start delimiter.
end_delimiter (Optional[str]) Sub string end delimiter.
list[str] A list of extracted substrings.
to_ascii Converts a string to ASCII. text (str) The string to convert. str The ASCII representation of the string.

Examples:

  • StringUtil.decode_base64

    Code

    from string_utils import StringUtil
    
    # Decode a base64 encoded string
    decoded_text = StringUtil.decode_base64('dGVzdA==')
    print(decoded_text)
    

    Output

    test
    
  • StringUtil.encode_base64

    Code

    from string_utils import StringUtil
    
    # Encode a string to base64
    encoded_text = StringUtil.encode_base64('test')
    print(encoded_text)
    

    Output

    dGVzdA==
    
  • StringUtil.get_char_and_ascii_number_pairs

    Code

    from string_utils import StringUtil
    
    # Get the character and its ASCII number pairs
    pairs = StringUtil.get_char_and_ascii_number_pairs('test')
    print(pairs)
    

    Output

    [('t', 116), ('e', 101), ('s', 115), ('t', 116)]
    

Metadata

Release files for nrt-string-utils 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for nrt-string-utils 1.0.4
File Interpreter ABI Platform Actions
nrt_string_utils-1.0.4-py3-none-any.whl Python 3 none any Details for nrt_string_utils-1.0.4-py3-none-any.whl

Release files / nrt_string_utils-1.0.4-py3-none-any.whl

Download URL nrt_string_utils-1.0.4-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d1e1a29daf7124a9ae9cefd7b04cebb166078e5734beb3dae4caa0bb02977eb8
BLAKE2b-256 checksum
How to use checksums
a0ce83ec24ec61a24686c8fcf71497d9ad6f8c67b9ad9af38b2ffaf7b17d79f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Security for nrt-string-utils 1.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page