how to extract variable length string

isurunalaka

Active member
  • Oct 31, 2008
    810
    27
    28
    hi

    i just wanna extract the date shown(last data until meet the first comma) in first column to another column. anyone can help me?

    column 1
    abcde, 1234
    abcd, 12345
    abcdef, 123


    column 2
    1234
    12345
    123
     

    meedeniyats

    Active member
  • Aug 24, 2010
    552
    105
    43
    If you are a java programmer, you can use

    String input = "abcd, 12345";
    String output = input.substring(input.indexOf(",")+2);
    System.out.println("output:"+output);


    Otherwise use similar functions substring() and indexOf() of the language you are using. :)
     

    isurunalaka

    Active member
  • Oct 31, 2008
    810
    27
    28
    If you are a java programmer, you can use

    String input = "abcd, 12345";
    String output = input.substring(input.indexOf(",")+2);
    System.out.println("output:"+output);


    Otherwise use similar functions substring() and indexOf() of the language you are using. :)

    thnx. anyway i need to do this in ms excel.:)
     

    nadda86

    Member
    Jan 2, 2014
    30
    2
    0
    public synchronized List<String> getDateList() {
    List<String> dateList = new LinkedList<String>();
    PreparedStatement ps = null;
    Connection conn = null;
    Statement stmt = null;
    String sqlStr = "";
    String sql = "";
    ResultSet rs = null;
    sqlStr = "select COLUMNNAME from TABLENAME";

    try {
    conn = getJDBCConnection();
    ps = conn.prepareStatement(sqlStr);
    rs = ps.executeQuery();

    while (rs.next()) {
    dateList.add(rs.getString("COLUMNNAME").substring(rs.getString("COLUMNNAME").lastIndexOf(",") + 1));
    }
    rs.close();
     

    thinking_guy

    Well-known member
  • Apr 16, 2011
    4,718
    2,737
    113
    If the first cell is A1 and the second cell is B2 then insert the following formula to B2 cell.

    =MID(A1,FIND(",",A1,1)+1,LEN(A1)-FIND(",",A1,1))


    XCell.JPG
     

    harshana001

    Active member
  • Mar 3, 2008
    728
    203
    43
    40
    oka control panel eke "language and regional settings" (mage thiyenne XP) eken hadanna puluwan nedha?
    eke "regional option" tab eke "customize" button eka click karala balapn saho aniwa ethana thiyenawa.

    Uba use karanne win vista or latest version ekak nam sorry thamai mama danne na eka thiyenne kohedha kiyala but saho aniwa onama version ekaka oka thiyenne control panel eke

    ane mandha mama haridha nathnam wena wikarayak kiwwadha kiyala..any way mama mata hithuna de kiwwa. mata wadiya kadda kohomawath ba......
     
    Last edited: