<?php preg_match_all("/([0-9]+)(?:\[([^\]]*)\])?A/", "123[SomeText]A345[SomeOtherText]A678A", $matches); print_r($matches);?>
Standard input is empty
Array ( [0] => Array ( [0] => 123[SomeText]A [1] => 345[SomeOtherText]A [2] => 678A ) [1] => Array ( [0] => 123 [1] => 345 [2] => 678 ) [2] => Array ( [0] => SomeText [1] => SomeOtherText [2] => ) )
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!