h> getAllTextSubmatches ("M(1,2) = 0.1e-3;" =~ "M\\(([0-9]+),([0-9]+)\\) *= *([0-9.eE-]+);") :: [String]
["M(1,2) = 0.1e-3;","1","2","0.1e-3"]
If it doesn't match, you'll get an empty list. You can join the tail of the match list together with Data.List.intercalate, and print it out with putStrLn. The if null case would just return ().
To demonstrate some of the typeclass trickery going on here, you could ask for the results as an Array with Int indexes of String.
h> import Text.Regexp.Posix (getAllTextSubmatches, (=~))
h> import Data.Array ((!), Array)
h> let matches = getAllTextSubmatches ("M(1,2) = 0.1e-3;" =~ "M\\(([0-9]+),([0-9]+)\\) *= *([0-9.eE-]+);") :: Array Int String
h> matches
array (0,3) [(0,"M(1,2) = 0.1e-3;"),(1,"1"),(2,"2"),(3,"0.1e-3")]
h> map (matches !) [1..3]
["1","2","0.1e-3"]