Answered RegEx Improve

zackmark29

Active member
Joined
Apr 21, 2020
Messages
28
Programming Experience
Beginner
Can anyone tell me the other regex for this strings.

005 - TitleOfTheSeries - Feb 19, 2016

I tried my regex and it worked but maybe there's much simple than this
(\d+\s-\s\w.\w.\w.\w\w+\s-\s?\s\w+\s\d+,\s\d+)
 
.* (any character repeated) will also match. If you're trying to match certain parts maybe (?<nr>\d+) - (?<title>\w+) - (?<date>\w+ \d{2}, \d{4}), but then perhaps just a string.Split would be sufficient. There are many variations of regex expression that could be constructed to match that string when it doesn't have to match specifics about it. Any way, in your expression you are not taking advantage of Quantifiers in Regular Expressions (repeats)
 
.* (any character repeated) will also match. If you're trying to match certain parts maybe (?<nr>\d+) - (?<title>\w+) - (?<date>\w+ \d{2}, \d{4}), but then perhaps just a string.Split would be sufficient. There are many variations of regex expression that could be constructed to match that string when it doesn't have to match specifics about it. Any way, in your expression you are not taking advantage of Quantifiers in Regular Expressions (repeats)

Thanks again for the answer
I tried it but it's not capture all the episode - title - date
Here's the example

The total needed to capture is 140 but only 99 result with your given regex
 
I tried also this
(\d+) - (\w+) - (\w+ \d{1,3}, \d{4})

But sometimes, there's additional space between the title
Example this

028 - DolceAmore - Mar 23, 2016 (no space title)
029 - Dolce Amore - Mar 24, 2016 (with space title)
 
Last edited:
Optional elements can be set with ? in regex, for example ? (space-questionmark) matches an optional space.
 
Back
Top