What is a better way to write this regular expression?

Posted by rxgx on Stack Overflow See other posts from Stack Overflow or by rxgx
Published on 2010-03-26T22:12:29Z Indexed on 2010/03/26 22:33 UTC
Read the original article Hit count: 146

Filed under:
|
|

I am converting XML children into the element parameters and have a dirty regex script I used in Textmate. I know that dot (.) doesn't search for newlines, so this is how I got it to resolve.

Search

language="(.*)"
(.*)<education>(.*)(\n)?(.*)?(\n)?(.*)?(\n)?(.*)?</education>
(.*)<years>(.*)</years>
(.*)<grade>(.*)</grade>

Replace

grade="$13" language="$1" years="$11">
        <education>$3$4$5$6$7$8$9</education>

I know there's a better way to do this. Please help me build my regex skills further.

© Stack Overflow or respective owner

Related posts about textmate

Related posts about regex