import re


def get_molecular_barcode(record,
                          molecular_barcode_pattern):
    """Return the molecular barcode in the record name.

    Parameters
    ----------
    record : screed record
        screed record containing the molecular barcode
    molecular_barcode_pattern: regex pattern
        molecular barcode pattern to detect in the record name
    Returns
    -------
    barcode : str
        Return molecular barcode from the name,if it doesn't exit, returns None
    """
    found_molecular_barcode = re.findall(molecular_barcode_pattern,
                                         record['name'])

    if found_molecular_barcode:
        return found_molecular_barcode[0][1]