about summary refs log tree commit diff
path: root/universe/ac_types/regex.py
blob: e5203bedfae410cca65b11f267d9ef17cf790849 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import re
from test_utils import simple_assert


def remove(regex, x):
    """Attempt to remove the substring matching `re` from `x`."""
    return re.sub(regex, '', x)


# No occurence
simple_assert(remove(r'\s\([\w\s]+\)$', 'Atlas.CustomerId'),
              'Atlas.CustomerId',
              name="remove")
# Single occurence
simple_assert(remove(r'\s\([\w\s]+\)$',
                     'Atlas.CustomerId (adjusted for MCC IDs)'),
              'Atlas.CustomerId',
              name="remove")