MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / find_pattern

Function find_pattern

src/cluecode/finder.py:585–596  ·  view source on GitHub ↗

Find regex pattern in the text lines of file at location. Return all match groups joined as one unicode string. Only return unique items if unique is True.

(location, pattern, unique=False)

Source from the content-addressed store, hash-verified

583
584
585def find_pattern(location, pattern, unique=False):
586 """
587 Find regex pattern in the text lines of file at location.
588 Return all match groups joined as one unicode string.
589 Only return unique items if unique is True.
590 """
591 pattern = re.compile(pattern, re.UNICODE | re.IGNORECASE)
592 matches = find(location, [(None, pattern,)])
593 if unique:
594 matches = unique_filter(matches)
595 for _key, match , _line, line_number in matches:
596 yield match, line_number

Callers

nothing calls this directly

Calls 2

findFunction · 0.85
unique_filterFunction · 0.85

Tested by

no test coverage detected