Python Forum
Help getting a string out of regex
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help getting a string out of regex
#2
You don't join things into a list. If you have one element you want to add, you .append() it. If you have another list you want to tack onto the end you .extend() it.

re.findall should return a list (of possibly identical items), so extending is I guess what you want...

match = ["match1", "match2"]
y = ["item1"]
y.extend(match)
print(y)
Output:
['item1', 'match1', 'match2']
Reply


Messages In This Thread
RE: Help getting a string out of regex - by bowlofred - Dec-01-2020, 05:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Regex: a string does not starts and ends with the same character Melcu54 5 2,479 Jul-04-2021, 07:51 PM
Last Post: Melcu54
  Please support regex for version number (digits and dots) from a string Tecuma 4 3,261 Aug-17-2020, 09:59 AM
Last Post: Tecuma
  regex match in a string batchen 4 3,267 Jan-20-2020, 08:48 AM
Last Post: batchen

Forum Jump:

User Panel Messages

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