arrow-py / arrow-py/arrow

Return matched string after successful parsing

Open
#897 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
9.1k
Forks
784
PR merge metrics
No merged PRs in 30d

Description

## Feature Request

Desiderata: have a way to retrieve the part of the string that `arrow` matched to the format in a successful parse.

I see at least two use cases.

### Get the "rest"

It is not an uncommon need, at least in the domain of web scraping, to extract a date from a string **and** to store the remaining information from that string somewhere else.

Getting the date with `arrow` is awesomely easy, but once I have that I don't know of a good way to "remove the date I extracted and get the rest of the string", other than formatting the date with all the formats and replacing it in the string.

Even that is not bulletproof, though, because

### Multiple matches

Suppose I want **all** the dates that match a certain format in a string? As it is now, I only get the result from the first match.

If I had the information of where the result was matched, I could at least call `get` again on the substring right after the match.

Contributor guide

No contributing guide indexed for this repository

Research direction

No files or tests are named. Start at arrow's parsing API and the get entry point described in the issue, then trace how the first successful match is returned. Done should provide the matched portion or its location so callers can retrieve the remaining string and find subsequent matches.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.