![]() |
|
![]() |
| LinkBack | Thread Tools | Display Modes |
| | #1 (permalink) |
| Junior Member Join Date: Nov 2008 Age: 32
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 2 | 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 |
| | |
| | #2 (permalink) |
| Junior Member Join Date: Nov 2008 Age: 32
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 2 | 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. |
| | |
![]() |
| Tags |
| remove , string |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
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 |
| More Interview Questions Here... |