SURESHKUMAR.NET FORUMS
Registered Member Login:
Not a member? Register today!



Welcome to the SURESHKUMAR.NET FORUMS.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.




Need to remove zero from a string

        

Reply
 
LinkBack Thread Tools Display Modes
Old 16-03-09, 08:23 AM   #1 (permalink)
Junior Member
 
Join Date: Nov 2008
Age: 32
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 2 av1978 is on a distinguished road
Unhappy Need to remove zero from a string

Hi,

In one of my task i need to strip off zero from a string. In the following variable declaration :

var i = A010; (Alphanumeric format type which has 10 spaces)


i need to strip off zero between A and 1. i should not remove the zero which comes after 1.

By using IndexOf i can get the first occurance of zero from this.

Here if i use IndexOf it would be return me a value of 1. Whether i can check what is the value of this 1st position. If the 1st position value is zero i need to strip off it from the string.

How can i do it? Could you please help me out.

I know i can't get the actual code here. But i need a guidance like any other stuff is there like to get the value of a string in a position and also what can i do for a strip off a value from a string?

Thanks in adv
am

av1978 is offline Offline   Reply With Quote
Old 25-03-09, 01:38 AM   #2 (permalink)
Junior Member
 
Join Date: Nov 2008
Age: 32
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 2 av1978 is on a distinguished road
Re: Need to remove zero from a string

Hi Guys,

finally i solved the issue.

the issue is : if we have a string like 000A0005 or A005 or A0050 we need to strip off zero between A and 5 and also the leading zeroes. Not the zero after 5.

Here how i solved it. i am giving a pesudocode if anyone needs the code i will post it.

Before this get the leading zeroes out so now u should be having A005, A0005, A0050.

(1) First i changed the string to chararrays

(2) Second i checked character.isdigit using a loop

(3) When the condition became true i added a counter.

(4) using counter i made a substring to get the character before the digit. (Here i got A which is before 0) and changed it to a string

(5) again another substring where i can get the characters remaining after the digit. (00050) and changed it to a string.

(6) stripped off the leading zeroes in the second string.

(7) concatnated the first and second string. Thus i got A5, A50.
av1978 is offline Offline   Reply With Quote
Reply

Tags
remove , string


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
interview Q&A asked in winrunner Spoorthi Testing Tools & QA 80 22-11-08 11:48 PM
Some VBScript Functions.. kiran2710 Testing Tools & QA 5 11-11-07 07:05 PM
Program to remove the trailing spaces from the string jithendra.b ds. c , c++ Interview / Technical Questions 1 05-05-07 01:19 PM
200 Amazing Secrets and Home tips(IMP) yathish FRIENDSHIP & LOVE 1 06-01-07 10:54 PM
Hello friends, i need help.. minamoda JAVA Technologies 4 28-03-06 04:54 AM


All times are GMT +6.5. The time now is 05:11 PM.

More Interview Questions Here...

Content Relevant URLs by vBSEO 3.3.2