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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:28:33+00:00 2026-05-30T13:28:33+00:00

Trying to write a regex that can parse a full name and split it

  • 0

Trying to write a regex that can parse a full name and split it into first name, middle name, last name. This should be easy but its pretty hard once you see the kind of names I have to parse. Now I could write a big long regex that takes into accout all these different cases but I think a smaller dynamic regex is possible and that’s why I am here asking for some help.

I think these are all of the types of names I have to grab.

Some example names that need to be parsed are(each have three commas at the end):

(first name) (middle intial). (last name),,, //one middle initial with period after
(first name) (last name),,,                  //simple first and last
(No name),,,                                 //no name
(first name) (last name)-(last name),,,      //two last names separated by a dash
(first name) (middle initial). (middle initial). (last name),,,   //two middle initials with space inbetween
(first name) (last name w/ apostrophe),,,    //Last names with apostrophes 
(first name) (Middle name) (Last name),,,    //first middle and last name
  • 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-30T13:28:35+00:00Added an answer on May 30, 2026 at 1:28 pm

    No code, but try:

    1. use substr to remove the last three characters off $name,
    2. @array = split /[\s+.]+/, $name # split on space and/or dots (as mentioned above) into an array,
    3. if ($array[0]) then you have a name,
    4. $lastname = pop @array; # gets the last (or only) name
    5. $firstname = shift @array if scalar @array; # first name is first element
    6. @array now contains all middle names and/or initials

    Something like that, anyway…

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

Sidebar

Related Questions

I'm trying to write a regex that will parse out the directory and filename
I am trying to write a regex that will allow me to parse CSV
I am trying to write a regex that matches the following: first an optional
I am trying to write a class that can parse an iCalendar file and
I am just trying to write a small web page that can parse some
I'm trying to write some replacement regex that will insert a locale code into
I am trying to write a custom code generator that can parse stored procedures.
I'm trying to write a regex expression that will take this phrase [[32, 120],
I'm trying to figure out how to write a regex that can detect if
I'm trying to write a regex that will match everything BUT an apostrophe that

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.