Windows Vista Forums

Re: Extracting the last char from the string
  1. #1


    sa Guest

    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

  2. #2


    Tom Lavedas Guest

    Re: Extracting the last char from the string

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

    > 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

  3. #3


    sa Guest

    Re: Extracting the last char from the string

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

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

    > > 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/- Hide quoted text -
    >
    > - Show quoted text -
    Appreciate your help !!! Thanks!

      My System SpecsSystem Spec

  4. #4


    Steve Guest

    Re: Extracting the last char from the string

    sa wrote:

    >
    > 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

Re: Extracting the last char from the string problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Get single char from string by position ? Vilius Mockûnas VB Script 1 16 Aug 2009
double char? rs232 General Discussion 0 10 Jun 2009
Extracting drive, path, filebasename WITH string functions and NOT system function ??? Thomas Lebrecht VB Script 13 02 Apr 2009
Re: how to count number of certain char within string Kiron PowerShell 0 16 Jul 2008
Problem Calling String(char[] value) constructor Keith Hill [MVP] PowerShell 4 17 Jul 2006