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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:13:52+00:00 2026-05-25T22:13:52+00:00

I have a text containing expressions that may be generated by the regular expression

  • 0

I have a text containing expressions that may be generated by the regular expression “[1-9]?[0-9].[1-9]?[0-9].[1-9]?[0-9]”.

No I want to perform a regular replacement that puts a “0” in front of each part when there is no first digit. So for example the string “1.10.3” would turn into “01.10.03”.

My problem is that I don’t know how to capture the first digit if and only if there there is no second digit in the first part. Using something like “.?([0-9])[^0-9]” would capture the first digit even if there is another one. So “12.3.4” would be turned into “02.03.04” or “102.03.04”.

Do you have any idea if there is any regular expression that matches this case?

[Edit:]

I am using the VBScript Regexp Object v5.5 which supports lookaheads.

I tried to use the Regular Expression provided by the the answer of Mark Byers:

Set re = New RegExp
re.Global = True
re.Pattern = "(?:^|[^0-9])([0-9])(?![0-9])"
Dim x As String
x = "1.3.4 string"
x = re.replace(x, "0$1")
MsgBox (x)

unfortunately the result of this code is “010304 string” – the dots are stripped away. I tried to modify the pattern to match the dots and whitespaces like “(?:^|[^0-9])([0-9])([. ])” and then to replace with “0$1$2” but the result is the same.

Do you have any idea what the problem might be?

  • 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-25T22:13:52+00:00Added an answer on May 25, 2026 at 10:13 pm

    Using lookarounds you can find digits that are not next to another digit:

    (?<![0-9])[0-9](?![0-9])
    

    And without a lookbehind (as it is not supported by some popular regular expression engines):

    (^|[^0-9])([0-9])(?![0-9])
    

    See the second version online: Rubular


    Update

    Try this:

    re.Pattern = "(^|[^0-9])([0-9])(?![0-9])"
    Dim x As String
    x = "1.3.4 string"
    x = re.replace(x, "$1X$2")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text file containing a number of records. Each record is stored
I have a div, containing text and a few links. I want to trigger
Using .NET regular expressions. Let's say I have the following text: ddddddddddd And I
I have a text file containing ~300k rows. Each row has a varying number
I have a text column containing URLs that are uniqe. I need to do
I have a variable string text containing lets say ABCDEFGHIJKL. I want to trim
I have a text file containing some records. Each record is splitted in 4
i have text message and I want to check whether it is containing text
I have long text containing name that looks like something-something. This long text is
I have a text file containing 21000 strings (one line each) and 500 MB

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.