-
Notifications
You must be signed in to change notification settings - Fork 1
API Documentation
Currently the documentation is up-to-date for version 0.2.0 of datetime-matcher
.
- module
datetime_matcher
def search(self, search_dfregex: str, text: str) -> Optional[Match[str]]
Scan through string looking for a match to the pattern, returning a Match object, or None if no match was found.
Uses strftime codes within the dfregex search pattern to match against datetimes.
def match(self, search_dfregex: str, text: str) -> Optional[Match[str]]
Try to apply the pattern at the start of the string, returning a Match object, or None if no match was found.
Uses strftime codes within the dfregex search pattern to match against datetimes.
def findall(self, search_dfregex: str, text: str) -> List[Match[str]]
Return a list of all non-overlapping matches in the string.
Uses strftime codes within the dfregex search pattern to match against datetimes.
If one or more capturing groups are present in the pattern, return a list of groups; this will be a list of tuples if the pattern has more than one group.
Empty matches are included in the result.
def finditer(self, search_dfregex: str, text: str) -> Iterator[Match[str]]
Return an iterator over all non-overlapping matches in the string. For each match, the iterator returns a Match object.
Uses strftime codes within the dfregex search pattern to match against datetimes.
Empty matches are included in the result.
def sub(self, search_dfregex: str, replacement: str, text: str, count: int = 0) -> str
Return the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in string by the replacement repl. Backslash escapes in replacement are processed.
Uses strftime codes within a dfregex search pattern to extract and substitute datetimes.
If no matches are found, the original text is returned.
Use a non-zero count to limit the number of substitutions.
def extract_datetimes(self, dfregex: str, text: str, count: int = 0) -> Iterator[datetime]
Extracts the leftmost datetimes from text given a dfregex search string.
Uses strftime codes within a dfregex search pattern to extract datetimes.
Returns an Iterator over datetime objects.
Use a non-zero count to limit the number of extractions.
def extract_datetime(self, dfregex: str, text: str) -> Optional[datetime]
Extracts the leftmost datetime from text given a dfregex search string.
Uses strftime codes within a dfregex search pattern to extract the datetime.
Returns the matching datetime object if found, otherwise returns None.
def get_regex_from_dfregex(self, dfregex: str, is_capture_dfs: bool = False) -> str
Converts a dfregex search pattern to its corresponding conventional regex search pattern.
By default, the datetime format groups are not captured.