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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:55:03+00:00 2026-06-09T18:55:03+00:00

Trying to write a regex that can split title and author given the syntax:

  • 0

Trying to write a regex that can split title and author given the syntax:

Author Name – Title

The title can contain multiple “-“.

I have the following regex: ([^-]*) - (.*)

This works for most cases, e.g.

Douglas Adams - Life, The Universe & Everything

splits into Douglas Adams and Life, The Universe & Everything

but fails for double barrelled author names –
e.g. Ayize Jama-Everett - Some Book Title as I then get:

Author = Everett

So I want to change the exclusion group [^-] to exclude the group " - ", as hyphens in the name will not have spaces surrounding them.

How do I do this?

  • 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-09T18:55:04+00:00Added an answer on June 9, 2026 at 6:55 pm

    Looks like you need lazy quantifier:

    (.*?) - (.*)
    

    First group will get minimum number of symbols before -. The second will capture the rest. It’ll not match if there is no - in the string.

    Depending of how you’re using it. You can also force it match with whole string by adding start and end quantifiers:

    ^(.*?) - (.*)$
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to write a regex that can parse a full name and split it
I have been trying to write a regex that will remove whitespace following a
I am trying to write a regex that matches the following: first an optional
I'm trying to write a regex to match entries in delimited files that have
I am trying to write a regex that will match the following YACC expression:
I'm trying to figure out how to write a regex that can detect if
trying to write an regex that can find all patterns p = q=http://.*\.doc in
I'm trying to write a Regex that that will extract individual fields from a
I'm trying to write a regex that will match everything BUT an apostrophe that
I'm trying to write a RegEx that starts with the number 0 or ANY

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.