Skip to main content

Build Status

django-regex-field

Stores regular expressions in Django models.

A Brief Overview

The Django regex field app provides a custom field for a Django model that stores a regex. This provides the ability to easily store regexs and access them as compiled regular expressions from your models.

Storing and Retrieving a Regex

A regular expression can be stored and retrieved in a Django model as follows:

from django.db import models
from regex_field.fields import RegexField


class RegexModel(models.Model):
    regex = RegexField(max_length=128)


model_obj = RegexModel.objects.create(regex='a')

# Access the regex as a compiled regular expression
>>> print(model_obj.regex.match('b'))
None

Using regex flags

Flags can be provided in the field definition and will be applied when the regex is compiled. If you manually compile a regex object with other flags and set it on the model, those flags will not be preserved. Only the flags passed to the field's constructor are used.

import re
from django.db import models
from regex_field.fields import RegexField


class RegexModel(models.Model):
    regex = RegexField(max_length=128, re_flags=re.IGNORECASE)


model_obj = RegexModel.objects.create(regex='A')

# Case insensitive matching
>>> print(model_obj.regex.match('a') is not None)
True

Release files for django-regex-field 3.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-regex-field 3.1.0
File Size Uploaded
django-regex-field-3.1.0.tar.gz 8.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-regex-field 3.1.0
File Interpreter ABI Platform
django_regex_field-3.1.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 16.4 kB

Release files / django-regex-field-3.1.0.tar.gz

Download URL django-regex-field-3.1.0.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e17e7296e8d8c6fb68f30342eb6c88ec0336d811a22f7f180717f71e6c1e3fd6
BLAKE2b-256 checksum
How to use checksums
ca902f794e40e5a512abfa227efb7edd8ea50d780848aba98a74fc4f46998078
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

Release files / django_regex_field-3.1.0-py2.py3-none-any.whl

Download URL django_regex_field-3.1.0-py2.py3-none-any.whl
Size 8.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
8d4f5c8dd60f187cf45e11ea01011b86fc18bc15ff31de91a7fd438e2b1037a2
BLAKE2b-256 checksum
How to use checksums
d89999aaaf79948f032883f156dfe107a877c5a48467f2cf90aea32b7aebe55c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

Release history Release notifications | RSS feed

This release

3.1.0 This release

2 release files

3.0.3

2 release files

2.0.2

2 release files

2.0.0

2 release files

1.3.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.5

2 release files

0.1.4

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page