purga
purga

Reputation: 453

How can I get the regular expression correct?

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.

Upvotes: 0

Views: 155

Answers (3)

Bart Kiers
Bart Kiers

Reputation: 170148

Matrix\s+"[^"]+"\s+SPRING\s+\d\s+\d\s+\{(\s+-?\d+(\.\d+)?)+\s+}

Upvotes: 2

Guffa
Guffa

Reputation: 700242

A pattern like this should work for matching a matrix:

Matrix "(.*?)" SPRING (\d+) (\d+) \{(?:(\s+-?\d+\.\d+){4})+\s+\}

Upvotes: 1

Jeremy Stein
Jeremy Stein

Reputation: 19661

Matrix\s+"[^"]*"\s+SPRING\s+\d+\s+\d+\s+{[^}]*}

Upvotes: 2

Related Questions