<commit_before>from staticfiles.storage import staticfiles_storage
import re

PREFIX = '/static/'
STATIC_PATTERN = re.compile(r"""
(?P<quote>['"])  # the opening quotes
{prefix}         # the prefix
.*?              # everything else in the url
(?P=quote)       # the first matching closing quote
""".format(prefix=PREFIX), re.VERBOSE)
PREFIX_LEN = len(PREFIX)

def replace(static_url):
    quote = static_url[0]
    url = staticfiles_storage.url(static_url[1+PREFIX_LEN:-1])
    return "".join([quote, url, quote])

def replace_urls(text):
    return STATIC_PATTERN.sub(replace, text)
<commit_msg>Correctly use the regex replacement function to substitute all urls in a particular chunk of text<commit_after>from staticfiles.storage import staticfiles_storage
import re

PREFIX = '/static/'
STATIC_PATTERN = re.compile(r"""
(?P<quote>['"])  # the opening quotes
{prefix}         # the prefix
(?P<rest>.*?)    # everything else in the url
(?P=quote)       # the first matching closing quote
""".format(prefix=PREFIX), re.VERBOSE)
PREFIX_LEN = len(PREFIX)

def replace(static_url):
    quote = static_url.group('quote')
    url = staticfiles_storage.url(static_url.group('rest'))
    return "".join([quote, url, quote])

def replace_urls(text):
    return STATIC_PATTERN.sub(replace, text)

{'fraction_non_alphanumeric': 0.13188518231186966, 'fraction_numerical': 0.0023273855702094647, 'mean_word_length': 4.443037974683544, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3703411', 'n_tokens_mistral': 409, 'n_tokens_neox': 398, 'n_words': 110}