I'm struggling a little with my regex. It's matching but I would like to have between 1 and 3 repeating patterns. The variation of strings I am looking to match against:
D1000_U400_Mbps_TC4_P, D2_U2_Mbps_TC1_C, D0.5_U2.2_Mbps_TC1_C
D0.5_U2.2_Mbps_TC1_C
D2_U2_Mbps_TC1_C,D250_U50_Mbps_TC4_P
D25-50_U5-10_Mbps_TC3_C
Home Superfast
FWPlus_TC3_C, D0.5_U0.1_Mbps_TC3_P
Context:
- These strings represent different broadband speed types (D - Download speed, U - Upload speed, Mbps - Megabits per second, TC - Traffic Class (between 1-4), C or P (priority indicators)
- Home Superfast or FWPlus is an "abstract" representation of an entire string or part of a string: example: Home Superfast may be: D1000_U500_Mbps_TC1_P, whereas FWPlus_TC3_C may be: D100_U50_TC3_C (or may represent something else, but that's not important)
Note:
- Each line represents a possible string (I would only ever be matching on 1 line, not multiple lines)
- Comma-separated parts (minimum number of parts 1, maximum 3)
- there may or may not be a space between each part and the comma
Variations:
D[number]_U[number]_Mbps_TC[number]_[letter]
[text]_TC[number]_[letter]
[text]
D[number]-[number]_U[number]-[number]_Mbps_TC[number]_[letter]
My regex (which probably needs work):
((?!=,)((Home (Fast|Superfast|Ultrafast))|((FWPlus)+|((D([0-9.]|\-[0-9])+)\_(U([0-9.]|\-[0-9])+)\_(Mbps)))\_(TC[1-4])\_([P,C])))*
I can match, but I would like to match a pattern that is between 1-3 repeats, and I'm not sure if I got the first part right (?!=,)
How can I do that?
RegExr link: https://regexr.com/59att