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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:00:57+00:00 2026-06-19T01:00:57+00:00

I want to use split and regular expressions together to separate special codes in

  • 0

I want to use split and regular expressions together to separate special codes in a line.
This is my line:

14S15T3C16W17A0-20m0-7T

Now I want to separate out each item, and the items could be for e.g. 14S, 15T, 7T, etc.
It consists of random length of digits and one single alphabet after that digit:

E.g.: 125125125125125X or 11T.

There is also an exception which is the 0- and these will remain as they are, and must be separated out too.

I have made a regular expression myself:

Dim digits() As String = Regex.Split(line, "([0-9][A-Z]|0-)")

But the problem is that it only takes 1 digit of the combination, for example, if the line is 11T2B13D, it will separate it like this: 1, 1T, 2B, 1, 3D

How can I solve this problem?

  • 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-19T01:00:58+00:00Added an answer on June 19, 2026 at 1:00 am

    Since there will be a single alphabet character or a slash - (for the case of 0-) that ends each token, it can be split using Regex.Split with this regex:

    (?<=[-a-zA-Z])
    

    (?<=pattern) is zero-width (text not consumed) positive look-behind, and it will match if the text before the current position matches the pattern inside.

    The regex above just checks that the character before the current position is alphabet (upper or lower case) a-zA-Z or a dash -, and split at the current position.


    Alternatively, you can do this with Regex.Matches with this regex:

    [0-9]+[A-Za-z]|0-
    

    Since the number can be arbitrary long, you need the 1 or more quantifier +. The rest should be clear, since it is very close to what you have tried.


    Both method should have the same effect for valid input (according to your specification). However, when the input is invalid, Regex.Split approach will produce invalid tokens, while Regex.Matches approach produces valid tokens (it will skip invalid character/sequences).

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

Sidebar

Related Questions

I want to use regex to split some string like this @key='value' to key
I wish to use regular expressions to split words into groups of (vowels, not_vowels,
If I want a part of an array I can use [] or split
I want use this 1 for using Bar code or QR code scanner. I
I am trying to use regular expressions to parse a method in the following
I am very new programmer to Java regular expressions. I do not want to
If this is my string : blablabla (blablabla). Which regular expression should i use
I am having issues figuring out how to split on multiple delimiters using regular
So I'm completely new to regular expressions , and I'm trying to use Java's
I want use BYTE_ORDER macro in my Xcode project but i can't because i

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.