Python Forum
Cant contain variable in regex
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cant contain variable in regex
#1
hi all,

im going to add to my “np” variable cant contain there username ie “un”

ive tried Regexp(‘form.un.data’, message=‘cant contain your name’)

just as a test and it didnt work

can regex do variables even?

un = StringField('Username', [InputRequired(message='please enter your Username')])
    op = PasswordField('Current Password', [InputRequired(message='please enter your current password')])
    np = PasswordField('New Password', [InputRequired(message='please enter your new password'), EqualTo('cnp', message='must match confirm new password'), Length(min=12), Regexp('.*[a-z]', message='must contain one lower case'), Regexp('.*[A-Z]', message='must contain one upper case'), Regexp('.*[0-9]', message='must contain one number'), Regexp('.*[\¬\!\"\£\$\%\^\&\*\(\)\_\+\`\-\=\{\}\:\@\~\<\>\?\[\]\;\'\#\,\.\/\\\|]', message='must contain one special character')])
    cnp = PasswordField('Confirm New Password')
thanks,
rob
Reply
#2
You would not put it in quotes. In quotes, it is the str 'form.un.data'
Reply
#3
(Jun-11-2024, 07:19 PM)deanhystad Wrote: You would not put it in quotes. In quotes, it is the str 'form.un.data'

i get this error

Regexp(form.un.data, message='cant contain your name')])



                                                                                                                       ^^^^
NameError: name 'form' is not defined. Did you mean: 'format'?

C:\python>
Reply
#4
Please post entire form definition.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [regex] Good way to parse variable number of items? Winfried 4 3,401 May-15-2020, 01:54 PM
Last Post: Winfried
  How to assign a found regex expression to a variable Pedroski55 2 3,814 Nov-24-2018, 07:14 AM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020