Grab all escape codes from a string.
        Returns a list of all escape codes.
966971
def get_codes(s: Union[str, 'ChainedBase']) -> List[str]:
    
    return codegrabpat.findall(str(s))
125434
def _escape(self, s):
        
        for ch, r_ch in self.ESCAPE_SETS:
            s = s.replace(ch, r_ch)
        return s
612149
def escape_string_json(st):
    
    ret = []
    c = 0
    ln = len(st)

    escape_chmap = {
        b'\b': b'b',
        b'\f': b'f',
        b'\n': b'n',
        b'\r': b'r',
        b'\t': b't',
        b'\\': b'\\',
        b'\"': b'"',
        b'\/': b'/'
    }

    while c < ln:
        ch = st[c:c+1]
        if ch in escape_chmap:
            ret.append(b'\\' + escape_chmap[ch])
        elif ord(ch) < 0x20:
            ret.append(b'\\u%04X' % ord(ch))
        else:
            ret.append(ch)
        c += 1
    return b''.join(ret)
493614
def p_encaps_list_string(p):
    ''
    if p[1] == '':
        p[0] = p[2].decode('string_escape')
    else:
        p[0] = ast.BinaryOp('.', p[1], p[2].decode('string_escape'),
                            lineno=p.lineno(2))
1018930
def getAllRegexp():
    '''
        
    '''

    listAll = []

    ############################################################################
    ############################################################################

    # --------------------------------------------------------------------------
    # Dinamically collecting all the "official" modules
    # --------------------------------------------------------------------------

    # A list that will contain all of the module names
    all_modules = []

    # Grabbing all the module names
    for _, name, _ in pkgutil.iter_modules(osrframework.patterns.__path__):
        all_modules.append("osrframework.patterns." + name)

    # Iterating through all the module names to grab them
    for moduleName in all_modules:
        # Importing the module
        my_module = importlib.import_module(moduleName)

        # Getting all the classNames.
        classNames = [m[0] for m in inspect.getmembers(my_module, inspect.isclass) if m[1].__module__ == moduleName]

        # Dinamically grabbing the first class of the module. IT SHOULD BE ALONE!
        MyClass = getattr(my_module, classNames[0])

        # Instantiating the object
        newInstance = MyClass()

        # Adding to the list!
        listAll.append(newInstance)

    # --------------------------------------------------------------------------
    # Loading user-defined wrappers under [OSRFrameworkHOME]/plugins/patterns/
    # --------------------------------------------------------------------------

    # Creating the application paths
    paths = configuration.getConfigPath()

    newPath = os.path.abspath(paths["appPathPatterns"])

    # Inserting in the System Path
    if not newPath in sys.path:
        sys.path.append(newPath)

    userImportedModules = {}

    for module in os.listdir(newPath):
        if module[-3:] == '.py':
            current = module.replace('.py', '')
            userImportedModules[current] = __import__(current)

    del newPath

    userClasses = []

    # Iterating through all the files
    for userModule in userImportedModules.keys():

        my_module = userImportedModules[userModule]
        # Getting all the classNames.
        classNames = [m[0] for m in inspect.getmembers(my_module, inspect.isclass) if m[1].__module__ == userModule]

        # Dinamically grabbing the first class of the module. IT SHOULD BE ALONE!
        MyClass = getattr(my_module, classNames[0])

        # Instantiating the object
        newInstance = MyClass()

        # Adding to the list!
        userClasses.append(newInstance)

    # --------------------------------------------------------------------------
    # Overwriting original modules with the user plugins
    # --------------------------------------------------------------------------
    listToAdd = []
    for userClass in userClasses:
        for i, officialClass in enumerate(listAll):
            # Checking if the name is the same
            if str(userClass) == str(officialClass):
                # Replacing the official module if a user module exists for it
                listAll[i] = userClass
            else:
                if userClass not in listToAdd:
                    # Appending the new class
                    listToAdd.append(userClass)

    # Merging listAll and listToAdd
    listAll = listAll + listToAdd
    ############################################################################
    ############################################################################

    return listAll
855442
def tokenize_string(cls, string, separator):
        """"""
        results = []
        token = ""
        found_escape = False
        for c in string:
            if found_escape:
                if c == separator:
                    token += separator
                else:
                    token += "\\" + c
                found_escape = False
                continue
            if c == "\\":
                found_escape = True
            elif c == separator:
                results.append(token)
                token = ""
            else:
                token += c

        results.append(token)
        return results
153136
def Escape(self, string="", **_):
    """"""
    # Translate special escapes:
    self.stack[-1] += self.STRING_ESCAPES.get(string, string)
1129601
def _parse_and_return_quoted_string(self):
        
        result = []
        pos = self.pos + 1
        segment_begin = pos
        my_chr = my_unichr if isinstance(self.text, my_unicode) else utf8chr
        while pos < self.end:
            c = self.text[pos]
            if c < ' ' and c != '\t':
                self.skip_to(pos)
                self.error('Encountered a control character that isn\'t allowed in quoted strings.')
            elif c == '"':
                if segment_begin < pos:
                    result.append(self.text[segment_begin:pos])
                pos += 1
                return ''.join(result), True, pos
            elif c == '\\':
                if segment_begin < pos:
                    result.append(self.text[segment_begin:pos])
                pos += 1
                if pos >= self.end:
                    break
                c = self.text[pos]
                if c == 'u':
                    code_point, pos = self._handle_unicode_escape(pos)
                    result.append(my_chr(code_point))
                else:
                    char, pos = self._handle_escape(pos, c)
                    result.append(char)
                segment_begin = pos
            else:
                pos += 1
        self.error('Reached the end of stream while parsing quoted string.')
1102241
def findall(self, string):
        
        output = []
        for match in self.pattern.findall(string):
            if hasattr(match, 'strip'):
                match = [match]
            self._list_add(output, self.run(match))
        return output
791285
def escape_chars(text, chars):
    """"""
    text = str(text)
    chars = list(set(chars))
    if '\\' in chars:
        chars.remove('\\')
        chars.insert(0, '\\')
    for ch in chars:
        text = text.replace(ch, '\\' + ch)
    return text
719376
def escape_filter_chars(assertion_value, escape_mode=0):
    

    if isinstance(assertion_value, six.text_type):
        assertion_value = assertion_value.encode("utf_8")

    s = []
    for c in assertion_value:
        do_escape = False

        if str != bytes:  # Python 3
            pass
        else:  # Python 2
            c = ord(c)

        if escape_mode == 0:
            if c == ord('\\') or c == ord('*') \
                    or c == ord('(') or c == ord(')') \
                    or c == ord('\x00'):
                do_escape = True
        elif escape_mode == 1:
            if c < '0' or c > 'z' or c in "\\*()":
                do_escape = True
        elif escape_mode == 2:
            do_escape = True
        else:
            raise ValueError('escape_mode must be 0, 1 or 2.')

        if do_escape:
            s.append(b"\\%02x" % c)
        else:
            b = None
            if str != bytes:  # Python 3
                b = bytes([c])
            else:  # Python 2
                b = chr(c)
            s.append(b)

    return b''.join(s)
87644
public static String unescape(String s) {
        StringBuilder buf = new StringBuilder();
        int[] pos = new int[1];
        for (int i=0; i<s.length(); ) {
            char c = s.charAt(i++);
            if (c == '\\') {
                pos[0] = i;
                int e = unescapeAt(s, pos);
                if (e < 0) {
                    throw new IllegalArgumentException("Invalid escape sequence " +
                            s.substring(i-1, Math.min(i+8, s.length())));
                }
                buf.appendCodePoint(e);
                i = pos[0];
            } else {
                buf.append(c);
            }
        }
        return buf.toString();
    }
1017696
def parse_dict_strings(code):
    

    i = 0
    level = 0
    chunk_start = 0
    curr_paren = None

    for i, char in enumerate(code):
        if char in ["(", "[", "{"] and curr_paren is None:
            level += 1
        elif char in [")", "]", "}"] and curr_paren is None:
            level -= 1
        elif char in ['"', "'"]:
            if curr_paren == char:
                curr_paren = None
            elif curr_paren is None:
                curr_paren = char

        if level == 0 and char in [':', ','] and curr_paren is None:
            yield code[chunk_start: i].strip()
            chunk_start = i + 1

    yield code[chunk_start:i + 1].strip()
855544
private static List<String> extractInfo(String str) {
        int beg = 0;
        int end = 0;
        int len = str.length();
        List<String> parts = new ArrayList<>();
        while (end < len && !Character.isSpaceChar(str.charAt(end)))
            end++;
        parts.add(str.substring(beg,end));
        while (end < len && Character.isSpaceChar(str.charAt(end)))
            end++;
        beg = end;
        while (end < len && !Character.isSpaceChar(str.charAt(end)))
            end++;
        parts.add(str.substring(beg,end));
        return parts;
    }
269682
def get_tokens(self, format_string):
        
        return [t for t in self.tokenize_pattern.split(format_string) if t]
902536
def extract_keypairs(lines, regexer):
    """"""
    updates = {}
    for line in lines:
        # for consistency we must match the replacer and strip whitespace / newlines
        match = regexer.match(line.strip())
        if not match:
            continue
        k_v = match.groupdict()
        updates[k_v[Constants.KEY_GROUP]] = k_v[Constants.VALUE_GROUP]
    return updates
953597
def _escaped_token_to_subtoken_strings(self, escaped_token):
    
    # NOTE: This algorithm is greedy; it won't necessarily produce the "best"
    # list of subtokens.
    ret = []
    start = 0
    token_len = len(escaped_token)
    while start < token_len:
      for end in range(
          min(token_len, start + self._max_subtoken_len), start, -1):
        subtoken = escaped_token[start:end]
        if subtoken in self._subtoken_string_to_id:
          ret.append(subtoken)
          start = end
          break

      else:  # Did not break
        # If there is no possible encoding of the escaped token then one of the
        # characters in the token is not in the alphabet. This should be
        # impossible and would be indicative of a bug.
        assert False, "Token substring not found in subtoken vocabulary."

    return ret