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:

  1. start (?:network;.*;(?:0|1);)
  2. to nth element (indexed 0), add (?:[^|]+[|]){n} (replace n number skip), followed ([^|]+)

example:

(?:network;.*;(?:0|1);)(?:[^|]+[|]){3}([^|]+) 

regular expression visualization

debuggex demo

matches with in example. here's regex101 demo.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -