Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

239
Views
Python - How to find a word in string, then print only x letters afterwards

So with following im adding Script from a webpage to a dict:

script2 = []
script1 = soup.findAll("script")[2]
script2.append(script1)
print(script2)

The output is a wall of text, i only want to extract certain things out of it.

How do I filter after a special string and then only print x letters afterwards? With that i could extract everything I want out of it.

Note: I already tried it with json loads but it doesnt work here strangely (example of the script output: https://pastebin.com/xvzQ456P)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You should be able to do that with regex.

import re

script2 = ...

special_string = 'xxx'
x_letters_afterwards = 5

result = re.findall(special_string + "(.{" + x_letters_afterwards + "})", script2)

print(result)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!