import re


def get_jobid(s, queuing_system):
    """Process textual output from qsub to get the job id.
 
    GE:
 
      .....
      Your job 2844562 ("ENVtest") has been submitted
               ^^^^^^^
 
    PBS:
 
      332161.gordon-fe2.local
      ^^^^^^^^^^^^^^^^^^^^^^^

    SLURM:

      .....
      Submitted batch job 835291
                          ^^^^^^
 
    """
    if queuing_system == "PBS":
        return s.strip()
    elif queuing_system == "GE":
        m =  re.search('Your job (?P<jobid>\d+) \("(?P<jobname>[^ "]+)"\)', s)
        if m:
            return m.group('jobid').strip()
    elif queuing_system == "SLURM":
        m =  re.search('Submitted batch job (?P<jobid>\d+)', s)
        if m:
            return m.group('jobid').strip()
    else:
        raise ValueError("Unknown queuing system %r" % queuing_system)
    return None