arkouda.match ============= .. py:module:: arkouda.match Classes ------- .. autoapisummary:: arkouda.match.Match Module Contents --------------- .. py:class:: Match(matched: arkouda.pdarrayclass.pdarray, starts: arkouda.pdarrayclass.pdarray, lengths: arkouda.pdarrayclass.pdarray, indices: arkouda.pdarrayclass.pdarray, parent_entry_name: str, match_type: MatchType, pattern: str) .. py:method:: end() -> arkouda.pdarrayclass.pdarray Returns the ends of matches :returns: The end positions of matches :rtype: pdarray, int64 .. rubric:: Examples >>> strings = ak.array(['1_2___', '____', '3', '__4___5____6___7', '']) >>> strings.search('_+').end() array([2 4 2]) .. py:method:: find_matches(return_match_origins: bool = False) Return all matches as a new Strings object :param return_match_origins: If True, return a pdarray containing the index of the original string each pattern match is from :type return_match_origins: bool :returns: * *Strings* -- Strings object containing only matches * *pdarray, int64 (optional)* -- The index of the original string each pattern match is from :raises RuntimeError: Raised if there is a server-side error thrown .. rubric:: Examples >>> strings = ak.array(['1_2___', '____', '3', '__4___5____6___7', '']) >>> strings.search('_+').find_matches(return_match_origins=True) (array(['_', '____', '__']), array([0 1 3])) .. py:method:: group(group_num: int = 0, return_group_origins: bool = False) Returns a new Strings containing the capture group corresponding to group_num. For the default, group_num=0, return the full match :param group_num: The index of the capture group to be returned :type group_num: int :param return_group_origins: If True, return a pdarray containing the index of the original string each capture group is from :type return_group_origins: bool :returns: * *Strings* -- Strings object containing only the capture groups corresponding to group_num * *pdarray, int64 (optional)* -- The index of the original string each group is from .. rubric:: Examples >>> strings = ak.array(["Isaac Newton, physics", '<-calculus->', 'Gottfried Leibniz, math']) >>> m = strings.search("(\w+) (\w+)") >>> m.group() array(['Isaac Newton', 'Gottfried Leibniz']) >>> m.group(1) array(['Isaac', 'Gottfried']) >>> m.group(2, return_group_origins=True) (array(['Newton', 'Leibniz']), array([0 2])) .. py:method:: match_type() -> str Returns the type of the Match object :returns: MatchType of the Match object :rtype: str .. rubric:: Examples >>> strings = ak.array(['1_2___', '____', '3', '__4___5____6___7', '']) >>> strings.search('_+').match_type() 'SEARCH' .. py:method:: matched() -> arkouda.pdarrayclass.pdarray Returns a boolean array indiciating whether each element matched :returns: True for elements that match, False otherwise :rtype: pdarray, bool .. rubric:: Examples >>> strings = ak.array(['1_2___', '____', '3', '__4___5____6___7', '']) >>> strings.search('_+').matched() array([True True False True False]) .. py:attribute:: re .. py:method:: start() -> arkouda.pdarrayclass.pdarray Returns the starts of matches :returns: The start positions of matches :rtype: pdarray, int64 .. rubric:: Examples >>> strings = ak.array(['1_2___', '____', '3', '__4___5____6___7', '']) >>> strings.search('_+').start() array([1 0 0])