how can i generate a regular-expression of the form (...)(.*?)(...) in order to match the first element of both matrices? i tried (Thermal expansion.*?steps\n +)(.*?)( +) (Thermal expansion.*?steps\n {1,2})(.*?)( {1,2} but neither did work. what am i missing? (i need the (...)(.*?)(...) form because my program is scanning files which do not only contain numbers. Thermal expansion (te) tensor [1/K] of composite Convergence: 5.50149e-02 in 1000 steps 3.2060307674e-04 -7.1247170199e-07 -5.3114135695e-06 -7.1247170199e-07 8.4889588014e-06 1.0496506193e-06 -5.3114135695e-06 1.0496506193e-06 2.9575863580e-04 Thermal expansion (te) tensor [1/K] of composite Convergence: 5.50149e-02 in 1000 steps -3.2060307674e-04 -7.1247170199e-07 -5.3114135695e-06 7.1247170199e-07 8.4889588014e-06 -1.0496506193e-06 -5.3114135695e-06 1.0496506193e-06 2.9575863580e-04