Python Forum
Having trouble with regular expressions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Having trouble with regular expressions
#2
It retrieves all strings that consist of:
  • One or more digits followed by,
  • exactly one digit.

The strings in your answer: '19', '456', and '20' are all the substrings in your original that meet those conditions.

't' isn't a digit, so 't' isn't part of the match string that is returned. But '19' satisfies all the conditions, so is returned.

'1' isn't a valid answer because your match requires a minimum of 2 digits that are adjacent to each other.
Reply


Messages In This Thread
Having trouble with regular expressions - by mikla - Mar-16-2021, 01:40 AM
RE: Having trouble with regular expressions - by bowlofred - Mar-16-2021, 03:01 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Use or raw string on regular expressions Zaya_pool 5 447 May-09-2024, 06:10 PM
Last Post: Zaya_pool
Information Do regular expressions still need raw strings? bobmon 3 452 May-03-2024, 09:05 AM
Last Post: rishika24
  Recursive regular expressions in Python risu252 2 1,512 Jul-25-2023, 12:59 PM
Last Post: risu252
Sad Regular Expressions - so close yet so far bigpapa 5 1,132 May-03-2023, 08:18 AM
Last Post: bowlofred
  Regular Expressions pprod 4 3,232 Nov-13-2020, 07:45 AM
Last Post: pprod
  Format phonenumbers - regular expressions Viking 2 2,013 May-11-2020, 07:27 PM
Last Post: Viking
  regular expressions in openpyxl. format picnic 0 2,559 Mar-28-2020, 09:47 PM
Last Post: picnic
  Unexpected (?) result with regular expressions guraknugen 2 2,315 Jan-18-2020, 02:33 PM
Last Post: guraknugen
  Strange output with regular expressions newbieAuggie2019 1 2,002 Nov-04-2019, 07:06 PM
Last Post: newbieAuggie2019
  Regular Expressions amitalable 4 2,854 Mar-14-2019, 04:31 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

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