Python Forum
Regex find string then return 10 character after it
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Regex find string then return 10 character after it
#2
You may be over complicating this (or maybe I'm over simplifying it) because you could achieve the objective with a simple sting slice:

text_string = "For some reason x:is in this string"

varX = "x:"

index = text_string.find(varX)+len(varX)

print(text_string[index:index+10])
pyStund likes this post
Sig:
>>> import this

The UNIX philosophy: "Do one thing, and do it well."

"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse

"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein
Reply


Messages In This Thread
RE: Regex find string then return 10 character after it - by rob101 - Aug-02-2022, 05:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Efficient method to find phrase in string Tuxedo 6 3,153 Feb-25-2021, 07:23 PM
Last Post: Tuxedo
  A function to return only certain columns with certain string illmattic 2 2,290 Jul-24-2020, 12:57 PM
Last Post: illmattic
  Match string return different cell string Kristenl2784 0 1,472 Jul-20-2020, 07:54 PM
Last Post: Kristenl2784
  How to return values from For Loop via return in a function AykutRobotics 14 8,611 Jan-08-2019, 04:12 AM
Last Post: stullis

Forum Jump:

User Panel Messages

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