Every line of 'python strip multiple characters' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
48 def strip(s, chars=''): 49 return ''
86 def stripIllegalChars(str): 87 88 # If the char separates a word, e.g. Face/Off, we need to preserve that separation with a - 89 str = re.sub(r'(?<=\S)[' + patterns.illegalChars + r'](?=\S)', '-', str) 90 91 # If it terminates another word, e.g. Mission: Impossible, we replace it, and any surrounding spaces with a single space 92 str = re.sub(r'\s?[' + patterns.illegalChars + r']\s?', ' ', str) 93 94 return str
42 def remove(value, delete_chars): 43 for c in delete_chars: 44 value = value.replace(c, '') 45 return value
533 def strip_string(self, string, mode='both', characters=None): 534 """Remove leading and/or trailing whitespaces from the given string. 535 536 ``mode`` is either ``left`` to remove leading characters, ``right`` to 537 remove trailing characters, ``both`` (default) to remove the 538 characters from both sides of the string or ``none`` to return the 539 unmodified string. 540 541 If the optional ``characters`` is given, it must be a string and the 542 characters in the string will be stripped in the string. Please note, 543 that this is not a substring to be removed but a list of characters, 544 see the example below. 545 546 Examples: 547 | ${stripped}= | Strip String | ${SPACE}Hello${SPACE} | | 548 | Should Be Equal | ${stripped} | Hello | | 549 | ${stripped}= | Strip String | ${SPACE}Hello${SPACE} | mode=left | 550 | Should Be Equal | ${stripped} | Hello${SPACE} | | 551 | ${stripped}= | Strip String | aabaHelloeee | characters=abe | 552 | Should Be Equal | ${stripped} | Hello | | 553 554 New in Robot Framework 3.0. 555 """ 556 try: 557 method = {'BOTH': string.strip, 558 'LEFT': string.lstrip, 559 'RIGHT': string.rstrip, 560 'NONE': lambda characters: string}[mode.upper()] 561 except KeyError: 562 raise ValueError("Invalid mode '%s'." % mode) 563 return method(characters)
12 def _strip_tags(value): 13 """ 14 Returns the given HTML with all tags stripped. 15 16 This is a copy of django.utils.html.strip_tags, except that it adds some 17 whitespace in between replaced tags to make sure words are not erroneously 18 concatenated. 19 """ 20 return re.sub(r'<[^>]*?>', ' ', force_unicode(value))