You need PCRE to get all the numbers from such a string with a regular

(3552214449, 4367, 17164, (128, 26, 12, 23, 0, 54, 230, 82)) 

Wrote such a regular season

 \(((\d+)\, ){3}\(((\d+), ){7}(\d+)\)\) 

But she told me only

  17164, 230, 82 

Then I simplified the task and tried to get only the first three numbers.

 \(((\d+)\, ){3} 

eventually got the group

Full match 0-26 (3552214449, 4367, 17164,

Group 1. 19-26 17164,

Group 2. 19-24 17164

Those. it got me only one third number. What I do not consider?

Even such a regular season

 (\d+\, ){3} 

Pulls out only the last value.

Full match 1-26 3552214449, 4367, 17164,

Group 1. 19-26 17164,

  • one
    There are as many parentheses in the expression as there are groups on the output. in order to get repetitions with brackets in general, a cycle is required in the language where you use pcre (well, or a specialized function, which makes for example an array of all occurrences) - Mike
  • @Mike Thanks for the clarification - Anton Shchyrov

1 answer 1

In general, after clarifying with @Mike, it was decided to split the problem into two. First, check the string for compliance with the mask

 ^\((\d+\, ){3}\((\d+\, ){7}\d+\)\)$ 

and then cycle through the numbers

 \d+ 
  • I may not understand what, but is not it easier to remove all the brackets and spaces with a simple replacement, and then cut them into an array of commas? - rjhdby
  • @rjhdby no. I need not just to get all the digits, but also to check the entire source line for compliance with the mask - Anton Shchyrov