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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:48:27+00:00 2026-06-12T09:48:27+00:00

I have a form field called ‘Name’ – but I’d like to save the

  • 0

I have a form field called ‘Name’ – but I’d like to save the submission into the DB as First Name & Last Name using a preg expression.

Can some illustrate how if I entered the name ‘John Smith’ into the field a regexp would strip this into First Name – John Surname – Smith

Thanks in advance

  • 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-12T09:48:28+00:00Added an answer on June 12, 2026 at 9:48 am

    Prefer use split (version php < 5.3.0) or explode which is an alias of split function, in your case, you just have to split you fullname with space character ' '

    var $fullname = "John Smith";
    var $splitfullname = $fullname.split(' ');
    
    var $firstname = $splitfullname[0];
    var $lastname = $splitfullname[1];
    

    –

    var $fullname = "John Smith";
    var $splitfullname = explode(' ', $fullname);
    
    var $firstname = $splitfullname[0];
    var $lastname = $splitfullname[1];
    

    if you build the form that catch firstname and fullname, I will suggest you to split your fullname input field into two input field (firstname and lastname).

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

Sidebar

Related Questions

I have a bean with a field called 'name', and a JSF form that
I have a form with input field which can be accessed like var algorithm
I have a form field where a user enters contact information, including name, email,
I have a text field called 'patentURL' in a form. The user enteres the
Rails 2.3.5 I have a form where there is a form field called 'MAX'
I have a form called ProductFamily . It has a field called ProductFamilyMBValues which
In my registration form I have a field called s_id . when i will
I have a form field which requires a json object as its value when
I have a form field: web_address = forms.RegexField(regex=r'^DO SOMETHING$', error_messages = {'invalid': _(Not a
I have a form I've built in PHP and storing the form field values

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.