tags:

views:

116

answers:

3

How can I write just one expression to represent the following cases? These Matrix Blocks all have similar structures, with the eception of different lines inside, varying all the way.

 Matrix "mat-31" SPRING 3 1 {
  0.000000 43.039398 0.000001 -0.000000
 }

 Matrix "mat-48" SPRING 3 2 {
  0.000000 1.000000 1.000000 1.000000
     3.495787 19.341287 0.234091 -23487819  
 }

 Matrix "mat-25" SPRING 3 4 {
  0.000000 12.855400 -0.000001 -10.844367
  3.234897 6.123478 23.239048 -13.787821
  6.234897 8.123721 23.239048 -18.342451
  1.234897 6.123478 23.239048 -19.453821

 }
 Matrix "mat-12" SPRING 3 3 {
  0.000000 1.000000 1.000000 1.000000
  7.232397 7.123478 8.239048 -1.453821
  3.889897 2.166474 -16.2443048 -9.453821
 }

Thanks in advance.

+1  A: 

A pattern like this should work for matching a matrix:

Matrix "(.*?)" SPRING (\d+) (\d+) \{(?:(\s+-?\d+\.\d+){4})+\s+\}
Guffa
thanks... will give me a try right back
You're not matching the spaces between the numbers in the body of the matrices.
Jeremy Stein
@Jeremy: You are right, the starting parenthesis was on the wrong side of the leading space.
Guffa
This still doesn't match the second example because the last number doesn't have a decimal point.
Jeremy Stein
+1  A: 
Matrix\s+"[^"]*"\s+SPRING\s+\d+\s+\d+\s+{[^}]*}
Jeremy Stein
This works correctly. Thanks!
+2  A: 
Matrix\s+"[^"]+"\s+SPRING\s+\d\s+\d\s+\{(\s+-?\d+(\.\d+)?)+\s+}
Bart Kiers
This works correctly. (Upvoted)
Jeremy Stein
This is working perfectly...thanks!