Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#15928 closed New feature (wontfix)

RegexField and regexp flags

Reported by: Sergey N. Belinsky <sergeybe@…> Owned by: nobody
Component: Forms Version: 1.3
Severity: Normal Keywords: RegexField unicode re.compile
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The syntax of re.compile function is:

regexp = re.compile(pattern[, flags])

but this function in RegexField used without flags. I suggest to use the next syntax for RegexField:

login = RegexField(r'\w+', flags=re.UNICODE|re.IGNORE)

I guess it will be useful. Thank you!

Change History (3)

comment:1 by anonymous, 13 years ago

Triage Stage: UnreviewedDesign decision needed

Based on the docs, RegexField.regex is a "regular expression specified either as a string or a compiled regular expression object.".

Your example could be written like this:

login = RegexField(re.compile(r'^\w+', flags=re.UNICODE|re.IGNORE))

And also like this—it's slightly shorter but less readable:

login = RegexField(r'(?ui)^\w+')

IMO this is sufficient and it's not necessary to add a flags parameter to RegexField, but others may feel differently. I'll mark the ticket as DDN.

comment:2 by anonymous, 13 years ago

Resolution: wontfix
Status: newclosed

Yes, you are right! I agree with you. Your examples are better. The extra parameter isn't need. Thank you!
I will close the ticket.

comment:3 by Jacob, 13 years ago

milestone: 1.4

Milestone 1.4 deleted

Note: See TracTickets for help on using tickets.
Back to Top