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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:59:28+00:00 2026-06-01T07:59:28+00:00

I working with some regular expression matching and I’m trying to figure out how

  • 0

I working with some regular expression matching and I’m trying to figure out how you would exclude a specific character pattern. Specifically, I want to exclude the following pattern:

5 -       #in words: digit, space, dash & space)

I know how to exclude the components individually: [^5 ^-] but I’m looking to exclude the specific pattern. Is this possible?

Update – I’m using Ruby as my programming language.

Here is some sample input and desired output.:

Input:  1 - Blue-Stork Stables; 2 - Young, Robert, S.; 3 - Seahorse Stable; 4 - Carney, Elvis; 5 - Guerrero, Juan, Carlos-Martin; 6 - Dubb, Michael; 7 - Summers, Hope; 8 - DTH Stables; 9 - Peebles, Matthew\n

the desired output would be:

Output: Blue-Stork Stables; Young, Robert, S.; Seahorse Stable; Carney, Elvis; Guerrero, Juan, Carlos-Marting; Dubb, Michael; Summers, Hope; DTH Stables; Peebles, Matthew\n

Please take note of the dashes on Blue-Stork Stables and Juan Carlos-Martin.

  • 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-01T07:59:30+00:00Added an answer on June 1, 2026 at 7:59 am

    EDIT: So you mean “remove”, not “exclude”. No problem:

    result = subject.gsub(/\d+ - /, '')
    

    transforms your input into the desired output. I’ve taken the liberty to allow more than one digit (after all, if numbers reach 10 or higher, you probably want to remove those entirely, too. Right?).


    (Old answer for “historical reasons”)

    Depending on what you mean by “exclude”, it appears that you’re looking for negative lookahead assertions:

    ^(?!.*\d - )
    

    will fail on strings that contain 5 - anywhere and succeed on all other strings:

    "5 - "       // fail
    "5 -"        // match
    "abc5 - xyz" // fail
    "foobar5 - " // fail
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using JavaScript to do some regular expression. Considering I'm working with well-formed source,
I'm having some trouble translating my working C# regular expression into JavaScript's regular expression
I need some help trying to figure out how to format dates in perl.
I have a very basic regular expression that I just can't figure out why
I'm writing a regular expression in javascript that replaces whitespaces except when: Some specific
Is it possible to map a URL pattern (regular expression or some other mapping)
I'm always fighting with regular expression, some help would be appreciated. What is the
I was trying to get a named regular expression working in F# without much
I really need some help in Regular Expressions, i'm working on a function like
I'm having some issues with a regular expression I'm creating. I need a regex

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.