polymerist.genutils.textual.substrings ====================================== .. py:module:: polymerist.genutils.textual.substrings .. autoapi-nested-parse:: For identifying and concatenating substrings of other strings with unique properties Functions --------- .. autoapisummary:: polymerist.genutils.textual.substrings.unique_string polymerist.genutils.textual.substrings.shortest_repeating_substring polymerist.genutils.textual.substrings.repeat_string_to_length Module Contents --------------- .. py:function:: unique_string(string: str, preserve_order: bool = True) -> str Accepts a string and returns another string containing only the UNIQUE characters in the origin string Can specify whether order is important with the "preserve_order" keyword :Parameters: * **string** (*str*) -- An arbitrary string on wants the unique characters from * **preserve_order** (*bool, default True*) -- Whether or not to keep the unique characters in the order they are found For example: unique_string("balaclava", preserve_order=False) -> "bcavl" unique_string("balaclava", preserve_order=True) -> "balcv" :returns: **uniquified_str** -- Another string containing only the unique characters in "string" Order depends on the value of the "preserve_order" parameter :rtype: str .. py:function:: shortest_repeating_substring(string: str) -> str Return the shortest substring such that the passed string can be written as some number of repeats (including 1) of the substring Will return the original string if no simpler decomposition exists .. py:function:: repeat_string_to_length(string: str, target_length: int, joiner: str = '') -> str Takes a string and repeats it cyclically to produce another string of a given length The number of times the original string occurs in the new string may be fractional for example: >> repeat_string_to_length("CAT", 6) -> "CATCAT" >> repeat_string_to_length("BACA", 10) -> "BACABACABA" :Parameters: * **string** (*str*) -- An arbitrary string to repeat * **target_length** (*int*) -- The length of the final desired string This does NOT have to be an integer multiple of the length of "string" E.g. repeat_string_to_length("BACA", 10) -> "BACABACABA" Nor does it have to be greater than the length of "string" E.g. repeat_string_to_length("BACA", 3) -> "BAC" :returns: **rep_string** -- A new string which has the desired target length and consists of cycles of the initial string :rtype: str