c++ - Regex repeat patterns and non matching groups -
okay having issue getting repeat work @ all, let alone way want work...
i bringing in string following information
network;pass;1;this text|can be|random|with|pipe|seperators;\r
what have far
(?:network;.*;(?:0|1);)([^|]*)
this leaves me first block matched
this text
what trying set can programmatically specify block match. text separated pipes have between 3-7 "blocks" , depending on situation may need match 1 of them, 1 @ time.
i had thought duplicating
([^|]*)
and adding non matching operator 1 cant seem match if duplicate group, , neither can repeat operators work on group.
i bit lost may not make entire sense if clarification required provide on request. appreciated.
why not split this text|can be|random|with|pipe|seperators
on pipe symbol? easier dynamically-generated regex.
but if want generate regex:
- start
(?:network;.*;(?:0|1);)
- to nth element (indexed 0), add
(?:[^|]+[|]){n}
(replacen
number skip), followed([^|]+)
example:
(?:network;.*;(?:0|1);)(?:[^|]+[|]){3}([^|]+)
matches with
in example. here's regex101 demo.
Comments
Post a Comment