locked
trim the string after the first comma RRS feed

  • Question

  • User564383478 posted

    Dears, I developed crystal report using the tool available with VS2005.

    I need help for extracting a string in a formula field.


    Example :

    String= CFG:1,132578992,1958|  result should be 132578992

    String= CFG:2,158974,1953|        result should be 158974

    in the string always starting part is "CFG" and ending part is "|" how can i trim the string after the first comma . how can i do this pls help me.

    Sunday, August 1, 2010 3:28 PM

Answers

  • User1224194097 posted

    do this way

    Replace(Split ({YourQueryColumnName},",")[2],"|","")
    
    Try that and see if it works for you

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, August 1, 2010 7:10 PM

All replies

  • User-1790381586 posted


                string original = "CFG:1,132578992,1958|";
    
                //Either should work
                string result1 = original.Split(',')[1];
    
                string result2 = original.Substring(original.IndexOf(',') + 1, original.LastIndexOf(',') - original.IndexOf(',') - 1);



    Sunday, August 1, 2010 3:53 PM
  • User1224194097 posted

    do this way

    Replace(Split ({YourQueryColumnName},",")[2],"|","")
    
    Try that and see if it works for you

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, August 1, 2010 7:10 PM