Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Re: Extracting the last char from the string

Reply
 
Old 11-18-2008   #1 (permalink)
sa


 
 

Re: Extracting the last char from the string

Hi,

I am stuck and need help. I have a string str which can have variuos
values ex.

str="C7,CR101,CR102,"
str="RF1003"
str="FE12,FE36,"

I need to have str without the comma. I have the code that I have
written and it does not work. Any ideas as to what is missing.

My Code
------------
findComma = Right(str,1)
start = len(str) -1
if findComma = "," then
mystring=Replace(str, findComma, "" , start ,1)
end if




My System SpecsSystem Spec
Old 11-18-2008   #2 (permalink)
Tom Lavedas


 
 

Re: Extracting the last char from the string

On Nov 18, 12:09*pm, sa <agarwasa2...@xxxxxx> wrote:
Quote:

> Hi,
>
> I am stuck and need help. I have a string str which can have variuos
> values ex.
>
> str="C7,CR101,CR102,"
> str="RF1003"
> str="FE12,FE36,"
>
> I need to have str without the comma. I have the code that I have
> written and it does not work. *Any ideas as to what is missing.
>
> My Code
> ------------
> findComma = Right(str,1)
> start = len(str) -1
> if findComma = "," then
> * * * * mystring=Replace(str, findComma, "" , start ,1)
> end if
How about ...

if Right(str,1) = "," then str = left(str, len(str) - 1)

Tom Lavedas
***********
http://there.is.no.more/tglbatch/
My System SpecsSystem Spec
Old 11-18-2008   #3 (permalink)
sa


 
 

Re: Extracting the last char from the string

On Nov 18, 10:44*am, Tom Lavedas <tglba...@xxxxxx> wrote:
Quote:

> On Nov 18, 12:09*pm, sa <agarwasa2...@xxxxxx> wrote:
>
>
>
>
>
Quote:

> > Hi,
>
Quote:

> > I am stuck and need help. I have a string str which can have variuos
> > values ex.
>
Quote:

> > str="C7,CR101,CR102,"
> > str="RF1003"
> > str="FE12,FE36,"
>
Quote:

> > I need to have str without the comma. I have the code that I have
> > written and it does not work. *Any ideas as to what is missing.
>
Quote:

> > My Code
> > ------------
> > findComma = Right(str,1)
> > start = len(str) -1
> > if findComma = "," then
> > * * * * mystring=Replace(str, findComma, "" , start ,1)
> > end if
>
> How about ...
>
> * if Right(str,1) = "," then str = left(str, len(str) - 1)
>
> Tom Lavedas
> ***********http://there.is.no.more/tglbatch/- Hide quoted text -
>
> - Show quoted text -
Appreciate your help !!! Thanks!
My System SpecsSystem Spec
Old 11-19-2008   #4 (permalink)
Steve


 
 

Re: Extracting the last char from the string

sa wrote:
Quote:

>
> I am stuck and need help. I have a string str which can have variuos
> values ex.
>
> str="C7,CR101,CR102,"
> str="RF1003"
> str="FE12,FE36,"
>
> I need to have str without the comma. I have the code that I have
> written and it does not work. Any ideas as to what is missing.
With New RegExp
.Pattern = ",$" ' match comma at end of string
For Each str In Array("C7,CR101,CR102,", "RF1003", "FE12,FE36,")
WScript.Echo .Replace(str, "")
Next
End With

--
Introduction to Regular Expressions (Scripting)
<http://msdn.microsoft.com/en-ca/library/6wzad2b2(VS.85).aspx>

--
Steve

We do not see things as they are, we see things as we are.
-Talmudic Saying


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Get single char from string by position ? VB Script
double char? General Discussion
Extracting drive, path, filebasename WITH string functions and NOT system function ??? VB Script
Re: how to count number of certain char within string PowerShell
Problem Calling String(char[] value) constructor PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46