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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:28:55+00:00 2026-06-15T13:28:55+00:00

string = First Name: John Last Name: Doe string2 = First Name: John Last

  • 0
string  = "First Name: John Last Name: Doe"
string2 = "First Name: John Last Name: Doe de Sour"
regex   = (First Name|Last Name): ([A-Za-z]+)

How can I modify my regex to also include “de Sour”? If I add a space like so:

regex   = (First Name|Last Name): ([A-Za-z ]+)

Then it’ll capture “Last Name” as well. The string is derived from the body contents of an email, so it’s important that I search for First Name and Last Name explicitly to get the contents after the “:”.

Expected return: ["First Name", "John"], ["Last Name", "De Sour"]

Important because I’ll be turning this into a Hash in Ruby.

  • 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-15T13:28:56+00:00Added an answer on June 15, 2026 at 1:28 pm

    I’d recommend turning this into a single regex that captures first name and last name at the same time (in different capture groups).

    regex = First Name: ([A-Za-z ]+) Last Name: ([A-Za-z ]+)
    

    You’ll have first name in capture group 1, last name in capture group 2. No chance of confusion with “first name” or “last name” since they’ve been explicitly called out.

    See it in action: http://rubular.com/r/qfA68b8PO5

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following XML: <current> <login_name>jd</login_name> </current> <people> <person> <first>John</first> <last>Doe</last> <login_name>jd</login_name> </preson> <person>
I have a customer table where I'm currently storing: Last Name First Name Middle
I have collection of similar strings for example : string 1: Customer's first Name
How do I seperate the Last Name and First Name into new columns? I
I have user's firstname and lastname in one string, with space between e.g. John
Using QString, one can do the following: QString const sentence = QString(First name: %1,
I've been trying to split a name into first and last name, but I'm
I have a json like this e.result = { 5474: { name: john, last:
I have class Person class person{ int ID ; sting FirstName ; string Last
I'm making a credit card processing form. The field in question is Name: (first

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.