I think I'd just use format() on the regex, being careful to escape '{' and
'}':

regex_f=r'^.*(?=.*{{{MIN},{MAX}}}*)(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!$%^
&*?@#-_+=])'
regex=regex_f.format(MIN=settings.MY_RE_MIN, MAX=settings.MY_RE_MAX)


On Thu, May 19, 2016 at 12:37 AM, Arun S <arun....@gmail.com> wrote:

> Hi,
>
> I have a Regular Expression something like this:
> regex=r'^.*(?=.*{8,}*)(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!$%^&*?@#-_+=])'
>                r'.*$',
>
> In this, i would like to read the values from the Django Setting file on
> the Max and Min Length and provide them as my input instead of Hard Coding.
>
> How can a Variable be provided/escaped in a regex.
> Can some one throw some light on this ?
>
> Cheers
> Arun
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/90556052-063e-4307-b095-c37a9920399b%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/90556052-063e-4307-b095-c37a9920399b%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD4ANxWXKPTst1QACxy%2BXbjJK0hF%2B1264Gs9oqafHRcwqRMSKg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to