My data from <script> returns None: AttributeError: ‘NoneType’ object has no attribute ‘group’

  beautifulsoup, python, python-3.x

I try to get the data from within the <script> tag but ‘model_data’ return None.
When I run the code I get the error:
model_data =
AttributeError: ‘NoneType’ object has no attribute ‘group’

What is wrong here?

html_doc = """
      var modelData = {
        "hlsUrl": "null",
        "account": "4LH7J44IYPAGEZEY6E3UL"

soup = BeautifulSoup(html_doc, "html.parser")
# locate the script, get the contents
script_text = soup.select_one("script").contents[0]

# get javascript object inside the script
model_data ="modelData = ({.*?});", script_text, flags=re.S)
print(model_data) # RETURNS None - why?
model_data =

# "convert" the javascript object to json-valid object
model_data = re.sub(
    r"^s*([^:s]+):", r'"":', model_data.replace("'", '"'), flags=re.M

# json decode the object
model_data = json.loads(model_data)

# print the data

Source: Python-3x Questions