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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:09:20+00:00 2026-05-21T04:09:20+00:00

Would anyone be able to assist me with some regex. I want to split

  • 0

Would anyone be able to assist me with some regex.

I want to split the following string into a number, string number

"810LN15"

1 method requires 810 to be returned, another requires LN and another should return 15.

The only real solution to this is using regex as the numbers will grow in length

What regex can I used to accomodate 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-05-21T04:09:21+00:00Added an answer on May 21, 2026 at 4:09 am

    String.split won’t give you the desired result, which I guess would be “810”, “LN”, “15”, since it would have to look for a token to split at and would strip that token.

    Try Pattern and Matcher instead, using this regex: (\d+)|([a-zA-Z]+), which would match any sequence of numbers and letters and get distinct number/text groups (i.e. “AA810LN15QQ12345” would result in the groups “AA”, “810”, “LN”, “15”, “QQ” and “12345”).

    Example:

    Pattern p = Pattern.compile("(\\d+)|([a-zA-Z]+)");
    Matcher m = p.matcher("810LN15");
    List<String> tokens = new LinkedList<String>();
    while(m.find())
    {
      String token = m.group( 1 ); //group 0 is always the entire match   
      tokens.add(token);
    }
    //now iterate through 'tokens' and check whether you have a number or text
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Would anyone be able to tell me what I'm doing wrong in the following
Would anyone be able to tell me why my following code doesn't centre the
Would anyone be able to point me to some sample java code that shows
Would anyone be able to point out some good tutorials on creating applications in
Would anyone be able to tell me how to pull the server name out
Would anyone be able to help me with how to get the file properties
So my quick question to everyone is, would anyone be able to explain to
Would anyone please be able to tell me the most efficient way to compare
I was wondering if anyone would be able to help me convert the below
I got lost in a using strpos() and ltrim()'s. Would anyone be able to

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.