Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 917293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:11:22+00:00 2026-05-15T18:11:22+00:00

I am trying to parse an output of about a hundred lines. The format

  • 0

I am trying to parse an output of about a hundred lines. The format of this output is as such:

<random text> STATION "STATION_NAME_ONE": <random text>
<random text> IP Address: 0.0.0.0 <random text>
<SEVERAL LINES OF RANDOM TEXT>

<random text> STATION "STATION_NAME_TWO": <random text>
<random text> IP Address: 1.1.1.1 <random text>
<SEVERAL LINES OF RANDOM TEXT>

... and so on

I know the IP Address of the station I am looking for. Using the IP address, I am trying to construct a regex that will find the station name. The station name can be any length and can contain any number of numbers/letters/underscores. The station name will always be preceded by STATION and will always be followed by a colon. The IP Address will always be on the line following the station name and will always be preceded by IP Address:.

Note there are several stations with different station names and IP Addresses. The ‘random text’ can be of any length and contain any symbol/number/letter.

So far my attempts have been:

re.search('(?<=STATION ).*?(?=:.*IP Address: %s)' % sta_ip, output, re.DOTALL)

but obviously this will return pretty much the first station name every time.

How would you make a regex that can search for the specified station name? Is this possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T18:11:23+00:00Added an answer on May 15, 2026 at 6:11 pm

    Edit
    I’ve got it. The key is that the station name and IP are only separated by one newline, so we can hardcode that newline.

    re.search('STATION(?P<StationName>.*?):.*?\n.*?IP Address: %s' % sta_ip, output).group("StationName")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse an output from a server that looks like this: {
Trying to parse xml to text I got something like this, INPUT FILE <Item
I'm trying to figure out how to better parse lines of text that have
I'm trying to parse the output from a tool into a data structure but
I'm trying to access the http://s3.amazonaws.com/commoncrawl/parse-output/segment/ bucket with boto. I can't figure out how
I am trying to parse some data from ifconfig output with sed, but I
I'm trying to write a Perl script that will parse the output of the
Trying to parse an HTML document and extract some elements (any links to text
Trying to parse some XML but apparently this is too much for a lazy
I'm trying to parse a local json file and the output is not what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.