Python Forum
Validate string using Regex
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Validate string using Regex
#2
A way to ignore the space is simply to allow white space together with the characters you mentioned. I would use
valid = re.match(r'^(?:[a-zA-Z0-9]|\s)*$', inp1) is not None
Tips:
  1. Always use raw strings when you write regexes, ie r''
  2. Python 2 support ends in 2020, use python 3.
Reply


Messages In This Thread
Validate string using Regex - by rahul_raj1981 - Jan-21-2018, 07:28 PM
RE: Validate string using Regex - by Gribouillis - Jan-21-2018, 08:32 PM
RE: Validate string using Regex - by rahul_raj1981 - Jan-23-2018, 05:05 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Not able to validate data from a file Zving 7 3,792 Apr-20-2019, 05:16 PM
Last Post: SheeppOSU

Forum Jump:

User Panel Messages

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