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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:52:24+00:00 2026-05-22T17:52:24+00:00

I have string looking like this: 01 02 03 99 I’d like to parse

  • 0

I have string looking like this:

01
02
03
99

I’d like to parse these to make them into strings like:

 1. 2. 3. 99. etc. 

The numbers are a maximum of 2 characters. Also I have to parse some more numbers later in the source string so I would like to learn the substring equivalent in javascript. Can someone give me advice on how I can do. Previously I had been doing it in C# with the following:

int.Parse(RowKey.Substring(0, 2)).ToString() + "."

Thanks

  • 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-22T17:52:25+00:00Added an answer on May 22, 2026 at 5:52 pm

    Why, parseInt of course.

    // Add 2 until end of string
    var originalA = "01020399";
    for (var i = 0; i < originalA.length; i += 2)
    {
      document.write(parseInt(originalA.substr(i, 2), 10) + ". ");
    }
    
    // Split on carriage returns
    var originalB = "01\n02\n03\n99";
    var strArrayB = originalB.split("\n");
    for (var i = 0; i < strArrayB.length; i++)
    {
      document.write(parseInt(strArrayB[i], 10) + ". ");
    }
    
    // Replace the leading zero with regular expressions
    var originalC = "01\n02\n03\n99";
    var strArrayC = originalC.split("\n");
    var regExpC = /^0/;
    for (var i = 0; i < strArrayC.length; i++)
    {
      document.write(strArrayC[i].replace(regExpC, "") + ". ");
    }
    

    The other notes are that JavaScript is weakly typed, so "a" + 1 returns "a1". Additionally, for substrings you can choose between substring(start, end) and substr(start, length). If you’re just trying to pull a single character, "abcdefg"[2] will return "c" (zero-based index, so 2 means the third character). You usually won’t have to worry about type-casting when it comes to simple numbers or letters.

    http://jsfiddle.net/mbwt4/3/

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

Sidebar

Related Questions

I have string looking like this: 'Toy Story..(II) (1995)' I want to split the
I have string like this /c SomeText\MoreText Some Text\More Text\Lol SomeText I want to
I have a string like this: Heading Some interesting text here HeadingSome interesting text
I'd like my website to have URLs looking like this: example.com/2010/02/my-first-post I have my
i have a session looking like this: array(1) { [31]=> array(10) { [aantal]=> int(1)
I have a string coming from a table like can no pay{1},as your payment{2}due
I have a string that has some Environment.Newline in it. I'd like to strip
I have a string that contains the representation of a date. It looks like:
I have this string 'john smith~123 Street~Apt 4~New York~NY~12345' Using JavaScript, what is the
Suppose I have a string such as this in a text file: (((var1 AND

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.