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
#3
@bowlofred, Thanks so much, that did get me closer to what I am aiming for. I am, however, trying to get a final output that is all one string, like this: Ok, I'll remind you in 4 days. I haven't set up the regular expression to take # day(s), yet; I am just using 'day' for simplicity's sake.

In any case, perhaps you can help me understand the output I am getting, now. Below is the raw output in the terminal (using print functions to try and help me understand what my code is doing):

Error:
INFO:root:starting message handling... INFO:root:waiting for next message day ['day'] Ok, I'll remind you in INFO:root:waiting for next message
And here's the updated code:

              y = "Ok, I'll remind you in "
                x = str(match[0])
                print(x)
                print(match)
                y.join(x)
                print(y)
                bot_handler.send_reply(message, y)
So, I'm a little confused why y.join(x) is not tacking 'day' onto the end of 'Ok, I'll remind you in '. Am I correct in understanding that x = str(match[0]) converts the 0th element of the list match to a string object equal to x? if so, why do I get 'Ok, I'll remind you in ' for print(y)?
Reply


Messages In This Thread
RE: Help getting a string out of regex - by matt_the_hall - Dec-01-2020, 09:21 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,474 Jul-04-2021, 07:51 PM
Last Post: Melcu54
  Please support regex for version number (digits and dots) from a string Tecuma 4 3,258 Aug-17-2020, 09:59 AM
Last Post: Tecuma
  regex match in a string batchen 4 3,263 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