1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-11-16 06:15:09 -05:00
SickRage/lib/fuzzywuzzy/string_processing.py
echel0n d7396896b5 Added in regex matching with fuzzy matching.
Shows now display Indexer absolute numbering.
Improved speed of parsing search results.
Fixed episode naming issues.
2014-05-31 03:35:11 -07:00

42 lines
1.1 KiB
Python

from __future__ import unicode_literals
import re
class StringProcessor(object):
"""
This class defines method to process strings in the most
efficient way. Ideally all the methods below use unicode strings
for both input and output.
"""
@classmethod
def replace_non_letters_non_numbers_with_whitespace(cls, a_string):
"""
This function replaces any sequence of non letters and non
numbers with a single white space.
"""
regex = re.compile(r"(?ui)\W")
return regex.sub(" ", a_string)
@classmethod
def strip(cls, a_string):
"""
This function strips leading and trailing white space.
"""
return a_string.strip()
@classmethod
def to_lower_case(cls, a_string):
"""
This function returns the lower-cased version of the string given.
"""
return a_string.lower()
@classmethod
def to_upper_case(cls, a_string):
"""
This function returns the upper-cased version of the string given.
"""
return a_string.upper()