ODBiC Discussion Board

RE: Cut of Last 4 character., Snehal, 07-15-2005

Several possible ways

by Roger Harris, July 16, 2005 17:02

If you're sure that it's always exactly 4 characters that you want to cut off, you can use this:

    $left($file_name$, $len($file_name$)-4)
If you're sure that it's always ".xls" that you want to drop, you can use this to replace that with an empty string:
    $repl($file_name$, ".xls"="")
Or, if you're sure there aren't any other "." characters before the ".xls" (or some other extension), you can use this to split the name there:
    $split($file_name$, ".")
If you can't be sure of any of those things and just want to cut off any file extension (if there is one), you might use a loop to find the last "." (if any) and truncate there:
    SET p = $len($file_name$);
    WHILE $p$ > 0;
        IF $mid($file_name$, $p$, 1) = ".";
            SET file_name = $left($file_name$, $p$-1);
        SET p = $p$ - 1;


Post Your Reply:

E-mail  optional

HTTP Link: 
Link text: 


Copyright ©1997-2003, Roger Harris. All rights reserved.