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 8041095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:06:17+00:00 2026-06-05T04:06:17+00:00

Long story short I am checking a rather lengthy error log. I would like

  • 0

Long story short I am checking a rather lengthy error log. I would like to find and parse the ip address associated with each error.

example I want to parse

client: 12.345.678.910

def check_file( file, string )
  File.open( file ) do |io|
    io.each do |line|
      result << parse_ip( line ) if line.include? string
    end
  end
  result
end

def parse_ip( flag )
  flag = flag.split.find_all{|word| /^client:.+/.match word}
  ip = flag. # need to grab ip here
  ip
end

Is there a simple way to get next word?

I am just not sure how to grab the characters following “client:”

Any assistance is appreciated.

EDIT: syntax error

  • 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-06-05T04:06:19+00:00Added an answer on June 5, 2026 at 4:06 am

    There are several ways to do it. For your example, you could extract the ip with a single regexp capture:

    def parse_ip( flag )
      m = /\bclient:\s*([\d\.]+)/.match flag
      m && m[1]
    end
    

    If you really prefer to tokenize with split for other reasons, you can use Enumerable#drop_while to scan to the key, then index to the next token:

    def parse_ip( flag )
      flag.split.drop_while{|token| token !~ /^client:/}[1]
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Long story short, when I submit a form, there are error messages under each
Long story short, I would like to take my usercontrols that are loaded dynamically
Long story short, I'm tired of the absurd concurrency rules associated with NSManagedObjectContext (or
Long story short: # this works as expected: logging.error(my_object.__unicode__()) # this doesn't: logging.error(my_object) Same
Long story short Say I have the following code: // a class like this
Long story short I need to get items based on a range (high/low value),
Long story short, we found files promoting prescription drugs on our server that we
Long story short, I have an ASP.NET application I'm trying to debug and at
Long story short, I'm developing a theme template for a blog that enables you
Long story short, the database I'm using needs to get looked at. Until that

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.