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

  • Home
  • SEARCH
  • 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 8612689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:41:22+00:00 2026-06-12T04:41:22+00:00

I need to obtain from a string version (of maximum 3 chars like sql

  • 0

I need to obtain from a string version (of maximum 3 chars like sql varchar(3), the “next version” with the following simple rule:

if its last chars constitutes a number, increment it, if it always fits max 3 chars, else, leave it as is.

Say “Hi1” => “Hi2”, “H9” => “H10” but “xx9” will remain unchanged.

  Public Shared Function GetNextVersion(oldVersion As String) As String
    Dim newVersion As String = String.Empty
    If Regex.IsMatch(oldVersion, "?????") Then
      Return newVersion
    Else
      Return oldVersion
    End If
  End Function
  • 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-12T04:41:24+00:00Added an answer on June 12, 2026 at 4:41 am

    This will be your regex, it will match anything with a gruop of letters followed by a group of numbers.

    Public Dim regex As Regex = New Regex( _
          "^(?<prefix>.*?0*)(?<version>\d+)$", _
          RegexOptions.IgnoreCase _
            Or RegexOptions.CultureInvariant _
            Or RegexOptions.Compiled _
        )
    

    It will contain two named capture groups, “prefix” which is the initial characters, and “version” which has your version.

    Cast the version to an int, increment it, and return the new version number by concatenating the prefix and new version.

    So, you’ll end up with something like this

    Public versionRegex As Regex = New Regex( _
       "^(?<prefix>.*?0*)(?<version>\d+)$", _
       RegexOptions.IgnoreCase _
         Or RegexOptions.CultureInvariant _
         Or RegexOptions.Compiled _
     )
    
    Public Shared Function GetNextVersion(oldVersion As String) As String
        Dim matches = versionRegex.Matches(oldVersion)
        If (matches.Count <= 0) Then
            Return oldVersion
        End If
    
        Dim match = matches(0)
        Dim prefix = match.Groups.Item("prefix").Value
        Dim version = CInt(match.Groups.Item("version").Value)
    
        Return String.Format("{0}{1}", prefix, version + 1)
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to obtain a Date object from this String:This is a example) M-27\nJUN-2012
I need to obtain the String for the file that is being uploaded from
I need to obtain time from my AnalogClock as a String and pass it
I need to obtain the Thread Id from a window create in runtime with
basically I have string s = Foo I need to obtain Type t =
When using the OAuth protocol, you need a secret string obtained from the service
I need to write a sql statement like this: SELECT id_segmento AS Segmento, Decode
I need to obtain the value from the Label Template Field which is bind
In my app I need to obtain some data from server. In eclipse I
I need to sort rows by due dates from XML: <plist version=1.0> <array> <array>

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.