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

  • Home
  • SEARCH
  • 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 8599431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:23:48+00:00 2026-06-12T01:23:48+00:00

I need to develop method that extracts the meaning from a string for a

  • 0

I need to develop method that extracts the meaning from a string for a record in a database. Here is an example of the a string:

MyString = "Purse $75,000. (up To $14,250 Nysbfoa) For Maidens, Fillies And Mares Three Years Old And Upward. Three Year Olds, 118 Lbs.; Older, 123 Lbs. One And One Eighth Miles. (Inner turf)"    

Given the string, I need to process it in such a way that I can create a race_record:

race_record[:purse] = 75000 
race_record[:race_type] = "Maidens"
race_record[:sex] = "Fillies And Mares"
race_record[:age] = "Three Year Old And Upward"
race_record[:distance] = "One And One Eighth Miles"
race_record[:surface] = "inner turf"

I was planning on to use ruby and a series of regular expressions to extract the data. For example:

race_record[:purse] = Mystring.scan(/(?<=\Purse\s[$])(.*?)(?=\.)/)
race_record[:race_type] = Mystring.sub(....)
etc.

My question isn’t so much what the correct regular expressions are. Given the objective, is the approach I proposed the right way to go, or is there a better approach or even a gem that can do the heavy lifting?

  • 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-12T01:23:49+00:00Added an answer on June 12, 2026 at 1:23 am

    You could use one regex to extract all the relevant parts into capturing groups at once;

    regexp = 
        /Purse\s\$          # Leading text
        ([\d,]+)            # Group 1
        .*?For\s            # Intervening text
        (\w+)               # Group 2
        ,\s                 # Intervening text
        (\w+\sAnd\s\w+)     # Group 3, etc. etc.
        \s
        ([^.]*)
        \.[^;]*;[^.]*\.\s
        ([^.]*)
        \.\s\(
        ([^()]*)
        \)/x
    

    Then you can do

    irb(main):025:0> match = regexp.match(mystring)
    => #<MatchData "Purse $75,000. (up To $14,250 Nysbfoa) For Maidens, Fillies And    Mares Three Years Old And Upward. Three Year Olds, 118 Lbs.; Older, 123 Lbs. One And One Eighth Miles. (Inner turf)" 
       1:"75,000" 2:"Maidens" 3:"Fillies And Mares" 4:"Three Years Old And Upward" 
       5:"One And One Eighth Miles" 6:"Inner turf">
    irb(main):026:0> match[1]
    => "75,000"
    irb(main):027:0> match[2]
    => "Maidens"
    ...etc.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From an application I need to develop, I've received a specific font that has
I need to develop an application on Android platform that enables a client to
I need to develop a service that will perform login through several login providers
I need to develop a Lotus Notes plug-in that adds some UI to Lotus
I need to develop an app that runs side by side with a django-app.
I develop a software that uses FlatOPC files. I need to manipulate several parts
I need to develop a new site with the e-commerce part. I'm here to
I need to develop a service that will connect to a TCP server. Main
Imagine that you need to develop and schedule an application/script to do the following:-
I develop a widget based on ViewGroup and my problem is that I need

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.