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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:01:12+00:00 2026-05-16T22:01:12+00:00

I am trying to parse some text files into a database and there is

  • 0

I am trying to parse some text files into a database and there is a string that includes 2 pieces of information in it.
There are a few options for what the string can look like.
It can either look like a single word Word or it can have that first word, followed by a dash, followed by any number of other words like Word - Second.
The key though, is that IF the string ends in a number like Word - Second 4 or two numbers separated by a slash like Word - Second 2/3 then those numbers need to be put into a different variable.

I do NOT know enough about regex to do this one. Help? (with explanations?)

  • 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-16T22:01:13+00:00Added an answer on May 16, 2026 at 10:01 pm

    I think you might be looking for something like this:

    ^([a-zA-Z]+(?: *- *[a-zA-Z]+(?: +[a-zA-Z]+)*)?)(?: +(\d+(?:\/\d+)?))?$
    

    Explanation:

    ^               Start of line
    (               First capturing group (for the words)
      [a-zA-Z]+     A word
      (?:...)?      (Omitted for clarity)
    )               Close first group
    (?:             Start non-capturing group
      \s+           Some whitespace
      (             Second capturing group (for the numbers)
        \d+         A number
        (?:\/\d+)?  Optionally a slash followed by another number
      )             Close capturing group
    )?              Close optional non-capturing group
    $               End of line
    

    I omitted an explanation of this part above: (?: *- *[a-zA-Z]+(?: +[a-zA-Z]+)*)?. It matches a dash followed by one or more space separated words. I also wrote \s in the explanation instead of because the space is invisible. But \s matches any whitespace, including new lines. You may prefer to match only spaces.

    Rubular

    • 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 some Text with parsec: data Cmd = LoginCmd String |
I'm trying to parse some UTF-8 encoded html text that contains the left and
I have a string: [\n['-','some text what\rcontains\nnewlines'],\n\n trying to parse: Regex.Split(@[\n['-','some text what contains
I am trying parse out some text that is in an html file. The
I am trying to parse some text and diagram it, like you would a
Trying to parse an HTML document and extract some elements (any links to text
I'm trying to parse some data in a fixed format text file where each
I am trying to parse some Makefile files to read some configs them them
I'm trying to parse some css files using a code project parser found here
I'm writing a program to parse some data saved as text files. What I

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.