Django Regex
Fields and utilities to work with regular expression in Django
The Django regex field provides custom fields and utilities for a Django model that stores a regex. This provides the ability to easily store regex patterns and access them as compiled regular expressions from your models.
Patterns can be expressed in perl syntax to set regex flags.
Components
RegexField
Django fields to store regular expressions
class DemoModel(models.Model):
regex = RegexField(flags=re.I)
o = DemoModel.objects.create(regex='^1$')
o.regex.match('1')
RegexFlagsField
As RegexField but allows to set compilation flags (see: https://docs.python.org/2/howto/regex.html#compilation-flags) It is rendered with proper widget
from django_regex.validators import compress
import re
class DemoModel(models.Model):
regex = RegexFlagsField()
o = DemoModel.objects.create(regex=compress(['aa', re.I]))
o.regex.match('AA')
o = DemoModel.objects.create(regex=compress(['aa', 'i'])) # use human shortcuts
o.regex.match('AA')
RegexFlagsField stores pattern and flags in the same db column as string in the format <regex.pattern><separator><regex.flags>
separator is chr(0) can be customized using settings DJANGO_REGEX_SEPARATOR or per each field using flags_separator argument.
from django_regex.validators import compress
import re
class DemoModel(models.Model):
regex = RegexFlagsField(flags_separator='/')
o = DemoModel.objects.create(regex='aa/i')
o.regex.match('AA')
RegexList
list that matches content against valid regular expressions
rules = RegexList(['\d*'])
1 in rules # True
'1' in rules # True
'a' in rules # False
Links
Stable |
|||
Development |
|||
Project home page: |
|||
Issue tracker: |
|||
Download: |
|||
Metadata
Release files for django-regex 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-regex-0.5.0.tar.gz | 26.2 kB | Without provenance | Details for django-regex-0.5.0.tar.gz |
Release files / django-regex-0.5.0.tar.gz
| Download URL | django-regex-0.5.0.tar.gz |
|---|---|
| Size | 26.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6af1add11ae5232f133a42754c9291f9113996b1294b048305d9f1a427bca27c
|
|
BLAKE2b-256 checksum How to use checksums |
0209f510713bb0d7f539b320579e2432d9aa8c02a7561bb9e3cdd37c658427d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 importlib_metadata/4.3.0 pkginfo/1.5.0.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.6.8
|
Security for django-regex 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.