Python Forum
AttributeError: 'NoneType' re.search
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AttributeError: 'NoneType' re.search
#2
You read the documentation?
Quote:re.search(pattern, string, flags=0)
Scan through string looking for the first location where the regular expression pattern produces a match, and return a corresponding Match. Return None if no position in the string matches the pattern; note that this is different from finding a zero-length match at some point in the string.
search returns None if there is no pattern match. You need to check that search() returned a match before using the match.
Reply


Messages In This Thread
RE: AttributeError: 'NoneType' re.search - by deanhystad - Jan-20-2024, 03:24 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python: Regex is not good for re.search (AttributeError: 'NoneType' object has no att Melcu54 9 1,743 Jun-28-2023, 11:13 AM
Last Post: Melcu54
  AttributeError: 'NoneType' object has no attribute 'group' MaartenRo 3 4,977 Jan-02-2022, 09:53 AM
Last Post: snippsat
  AttributeError: 'NoneType' object has no attribute 'group' MaartenRo 3 2,878 Jan-01-2022, 04:16 PM
Last Post: MaartenRo
  AttributeError: 'NoneType' object has no attribute 'next' loves 2 11,835 Dec-15-2020, 11:30 PM
Last Post: bowlofred
  AttributeError: 'NoneType' object has no attribute 'label' : What's wrong ? Etienne17 1 4,108 Dec-13-2019, 06:57 PM
Last Post: ibreeden
  AttributeError: 'NoneType' object has no attribute 'get' ahmeddedo 1 6,767 May-27-2019, 05:57 AM
Last Post: heiner55
  AttributeError: 'NoneType' object has no attribute 'n' in list of class objects jdrp 4 5,877 Jun-19-2018, 02:44 PM
Last Post: jdrp
  String substitution with dictionary - AttributeError: 'NoneType' Atalanttore 2 3,358 May-02-2018, 08:52 PM
Last Post: Atalanttore
  AttributeError: 'NoneType' object has no attribute 'get' BoaCoder3 2 30,363 Feb-03-2018, 07:17 PM
Last Post: BoaCoder3

Forum Jump:

User Panel Messages

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