import re


def parse_restorStr(s):
    """Extract the beam parameters from the output of MIRIAD RESTOR."""
    
    # Regular expressions 
    fwhmRe = re.compile('.*fwhm of\s+(\S+)\s+by\s+(\S+)\s+')
    paRe = re.compile('Position angle:\s+(\S+)\s+')

    beamMaj = None
    beamMin = None
    beamPA = None
    for line in s.split("\n"):
        mch = fwhmRe.match(line)
        if mch:
            beamMaj = float(mch.group(1))
            beamMin = float(mch.group(2))
        mch = paRe.match(line)
        if mch:
            beamPA = float(mch.group(1))

    return beamMaj, beamMin, beamPA