Quantifier for Ruby regex grouping -


I need a rabies reggae so that 11 groups can be separated by underscores, but more than 11 underscore. I need constant underscores to be understood as a "blank" group even though I have so far that & gt; 11 underscore points:

  / ^ (dw | lat) \ _ (. *) \ _ (Track-search | text-ed) \ _ (. *) \ _ (. *) \ _ (. *) \ _ (. *) \ _ (. *) \ _ (. *) \ _ (. *) $ /   

here Some examples are test cases.

must match:

lat_march madness update_Paid-search_subscription-one_google_ncaa-tournament_ {adid} _p__March172014_2

But not match: < / p>

lat_los angeles_Paid- search_nami-media_adn_jgYno0gS7yYjNq8OT7n_LcgTN9nt6vrmbC9qlcp __- 21150_49996_7006_April22014_4

Change your (. *) to ([^ _] *) . From this but _ will create a character square, and it will match 0 + times. In this way, the code is counted as the _ capture group, but only one delimiters, besides, _ is not a reserved character, therefore it is not necessary to avoid it. Last:

  ^ (dw | lat) _ ([^ _] *) _ (Paid-search | text-ed) _ ([^ _] *) _ ([^ _] *) _ ([^ _] *) _ ([^ _] *) _ ([^ _] *) _ ([^ _] *) _ ([^ _] *) _ ([^ _] *) $   

Update:

If you do not need to match your previous 8 capture groups, you clear Also forward:

  ^ (dw | lat) _ ([^ _] *) _ (Paid-search | text-ed) (?: _ [^ _] *) {8} $   

It just takes the final pattern and repeats it 8 times though, if you try to capture [^ _] * , Then of this L will miss the final event as the fourth capturing group (instead of remembering all 8).

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -