Removing number of characters from end of string

Hi all....
Dooza very kindly helped me with trimming a string in an
earlier post, but
now i want to remove the last four characters from a string.
I really should know how to do this and will have to do some
bedtime reading
:-|
But, for now, could someone help!
Thanks
Andy

Ah Dooza - Thank You.
To the rescue again :-D
You're helping me to see the logic...
Thanks Again
Andy
"Dooza" <[email protected]> wrote in message
news:gbafel$ra3$[email protected]..
> Andy wrote:
>> Hi all....
>> Dooza very kindly helped me with trimming a string
in an earlier post,
>> but now i want to remove the last four characters
from a string.
>> I really should know how to do this and will have to
do some bedtime
>> reading :-|
>>
>> But, for now, could someone help!
>
> Hi Andy,
> Try something like this:
> <%
> myStr = "this is my really long string"
> Response.Write(LEFT(myStr,LEN(myStr) -4))
> %>
>
> Dooza

Similar Messages

  • Removing Non-numeric characters from Alpha-numeric string

    Hi,
    I have one column in which i have Alpha-numeric data like
    COLUMN X
    +91 (876) 098 6789
    1-567-987-7655
    so on.
    I want to remove Non-numeric characters from above (space,'(',')',+,........)
    i want to write something generic (suppose some function to which i pass the column)
    thanks in advance,
    Mandip

    This variation uses the like operators pattern recognition to remove non alphanumeric characters. It also
    keeps decimals.
    Code Snippet
    CREATE FUNCTION dbo.RemoveChars(@Str varchar(1000))
    RETURNS VARCHAR(1000)
    BEGIN
    declare @NewStr varchar(1000),
    @i int
    set @i = 1
    set @NewStr = ''
    while @i <= len(@str)
    begin
    --grab digits or (| in regex) decimal
    if substring(@str,@i,1) like '%[0-9|.]%'
    begin
    set @NewStr = @NewStr + substring(@str,@i,1)
    end
    else
    begin
    set @NewStr = @NewStr
    end
    set @i = @i + 1
    end
    RETURN Rtrim(Ltrim(@NewStr))
    END
    GO
    Code to validate:
    Code Snippet
    declare @t table(
    TestStr varchar(100)
    insert into @t values ('+91 (8.76) \098 6789');
    insert into @t values ('1-567-987-7655');
    select dbo.RemoveChars(TestStr)
    from @t

  • Removing non-numeric characters from string

    Hi there,
    I need to have the ability to remove non-numeric characters from a string and I do not know how to do this.
    Does any one know a way?
    Example:
    Present String: (02)-2345-4607
    Required String: 0223454607
    Thanks in advance

    Dear NickM
    Try this this will work...........
    create or replace function char2num(mstring in varchar2) return integer
    is
    -- Function to remove Special characters and alphebets from phone no. string field
    -- Author - Valid Bharde.(India-Mumbai)
    -- Date :- 20 Sept 2006.
    -- This Function will return numeric representation.
    -- The Folowing program is gifted to NickM with respect to his post on oracle site regarding Removing non-numeric characters from string on the said date
    mstatus number :=0;
    mnum number:=0;
    mrefstring varchar2(50);
    begin
    mnum := length(mstring);
    for x in 1..mnum loop
    if (ASCII(substr(upper(mstring),x,1)) >= 48 and ASCII(substr(upper(mstring),x,1)) <= 57) then
    mrefstring := mrefstring || substr(mstring,x,1);
    end if;
    end loop;
    return mrefstring;
    end;
    copy the above program and use it at function for example
    SQL> select char2num('(022)-453452781') from dual;
    CHAR2NUM('(022)-453452781')
    22453452781
    Chao!!!

  • Removing Non-Ascii Characters from a String

    Hi Everyone,
    I would like to remove all NON-ASCII characters from a large string. For example, I am taking text from websites and would like to remove all the strange arabic and asian characters. How can I accomplish this?
    Thank you in advance.

    I would like to remove all NON-ASCII characters from a large string. I don't know if its a good method but try this:
    str="\u6789gj";
    output="";
    for(char c:str.toCharArray()){
         if((c&(char)0xff00)==0){
              output=output+c;
    System.out.println(output);
    all the strange arabic and asian characters.Don't call them so.... I am an Indian Muslim ;-) ....
    Thanks!

  • Removing the Control Characters from a text file

    Hi,
    I am using the java.util.regex.* package to removing the control characters from a text file. I got below programming from the java.sun site.
    I am able to successfully compile the file and the when I try to run the file I got the error as
    ------------------------------------------------------------------------D:\Debi\datamigration>java Control
    Exception in thread "main" java.util.regex.PatternSyntaxException: Illegal repet
    ition
    {cntrl}
    at java.util.regex.Pattern.error(Pattern.java:1472)
    at java.util.regex.Pattern.closure(Pattern.java:2473)
    at java.util.regex.Pattern.sequence(Pattern.java:1597)
    at java.util.regex.Pattern.expr(Pattern.java:1489)
    at java.util.regex.Pattern.compile(Pattern.java:1257)
    at java.util.regex.Pattern.<init>(Pattern.java:1013)
    at java.util.regex.Pattern.compile(Pattern.java:760)
    at Control.main(Control.java:24)
    Please help me on this issue.
    Thanks&Regards
    Debi
    import java.util.regex.*;
    import java.io.*;
    public class Control {
    public static void main(String[] args)
    throws Exception {
    //Create a file object with the file name
    //in the argument:
    File fin = new File("fileName1");
    File fout = new File("fileName2");
    //Open and input and output stream
    FileInputStream fis =
    new FileInputStream(fin);
    FileOutputStream fos =
    new FileOutputStream(fout);
    BufferedReader in = new BufferedReader(
    new InputStreamReader(fis));
    BufferedWriter out = new BufferedWriter(
    new OutputStreamWriter(fos));
         // The pattern matches control characters
    Pattern p = Pattern.compile("{cntrl}");
    Matcher m = p.matcher("");
    String aLine = null;
    while((aLine = in.readLine()) != null) {
    m.reset(aLine);
    //Replaces control characters with an empty
    //string.
    String result = m.replaceAll("");
    out.write(result);
    out.newLine();
    in.close();
    out.close();

    Hi,
    I used the code below with the \p, but I didn't able to complie the file. It gave me an
    D:\Debi\datamigration>javac Control.java
    Control.java:24: illegal escape character
    Pattern p = Pattern.compile("\p{cntrl}");
    ^
    1 error
    Please help me on this issue.
    Thanks&Regards
    Debi
    // The pattern matches control characters
    Pattern p = Pattern.compile("\p{cntrl}");
    Matcher m = p.matcher("");
    String aLine = null;

  • Remove un recognized characters from a field of a table.

    Is there any way to remove un recognized characters from content of field in a table. Please help.
    Thx

    If you know the characters that you want removed, you may have success using the TRANSLATE function.
    The key here as stated in the SQL Language Reference is
    the extra characters at the end of from_string have no corresponding characters in to_string. If these extra characters appear in char, then they are removed from the return value.
    The other useful function to remove unwanted junk is REGEXP_REPLACE - but you must be on 10g or later for regular expression support. Translate is supported at least as far back as 8i, perhaps further.

  • Reading in a certain number of characters from a file.

    Hi guys,
    I need some pointers on how to read in a specified number of characters from a text file.For example,how would I read in the first 100 characters to an array from a text file with an unspecfied number of characters (more than 100 rather than less!).
    At present I am getting code errors being thrown due to reading in beyond the array size ie
    java.lang.ArrayIndexOutOfBoundsException: 100.

    post more code , this exception tells me nothing
    without seeing what you are actually doing.
    public String getText (String file)//textfile to be analyzed will be inputted as argument 150407 0356
       //15042007 0612 Check notes on overloaded getText method below.
           int temp;
           inputFile = file;
           int i=0;
                try
                    BufferedReader bGetFile = new BufferedReader (new FileReader(inputFile));
                    while ((temp=bGetFile.read())!=-1)
                        textFromFile[i] = (char)temp;
                        i++;
                    /*for (int j=0;j<MAX;j++)
                        System.out.print(textFromFile[j]);//25042007 0208.For Testing purposes
                    inputText=new String(textFromFile).trim();
                    bGetFile.close();
                catch (IOException e)
                    System.out.println (" ");
                    System.out.println ("Sorry.An error occurred while trying to read from the input file.Unable to proceed!");
                System.out.println ("Processing the input text file "); //25042007 2318 being used for debugging purposes.          
                return inputText;
        }If the file being read is greater than MAX characters it will throw the exception mentioned.What I would like to do is read in MAX characters and discard the rest.

  • How to find number of characters in a character string

    Hi,
      Can anyone please tell me about how to find the number of characters in a character string type variable.
    Reagards,
    Siva

    hi,
    Use STRLEN for Calculating String Length..
    Assign it to integer variable for Further Use.Suppse u need to find string length for "hai".. this piece of code will help u
    data:  var type string value 'hai',
             len type i.
    len = strlen(var).
    write len.

  • Removing non printable characters from an excel file using powershell

    Hello,
    anyone know how to remove non printable characters from an excel file using powershell?
    thanks,
    jose.

    To add - Excel is a binary file.  It cannot be managed via external methods easily.  You can write a macro that can do this.  Post in the Excel forum and explain what you are seeing and get the MVPs there to show you how to use the macro facility
    to edit cells.  Outside of cell text "unprintable" characters are a normal part of Excel.
    ¯\_(ツ)_/¯

  • Removing number appended at the end from a string field

    Hi,
    I have a string field which has numbers appended to its end. I need to remove the numbers and display only the string values.
    The string is not of fixed length, and the numeric values can be single digit or 2 digits and might be separate by a space but not always.
    Here is some sample data:
    SHOWCASE NOTT12
    SHOWCASE PETE12
    SHOWCASE BRIST7
    SHOWCASE READI1
    CINEDROME PAD1
    RITZ BELPER   1
    STEPH.JOSEPH S1
    I need to display this as below (without any numbers appended at the end)
    SHOWCASE NOTT
    SHOWCASE PETE
    SHOWCASE BRIST
    SHOWCASE READI
    CINEDROME PAD
    RITZ BELPER  
    STEPH.JOSEPH S
    Please let me know how this can be achieved.
    Thanks!

    Hi there,
    Just a quick option is to use the REPLACE function, i.e.
    REPLACE(REPLACE(REPLACE({contr_actv.dept_id},'1' ,''),'2', ''), '3', '');
    You just have to build it up a little more so it caters for numbers 0 - 9.  At the moment it only works for numbers 1 - 3.  Another way you could do this is write some code to loop through the length of the string looking at each individual character to test for a number.
    I don't have time today to write something like that but the above should work as long as you don't have numbers in the middle of names etc.
    Cheers,
    Chris

  • Removing non english characters from my string input source

    Guys,
    I have problem where I need to remove all non english (Latin) characters from a string, what should be the right API to do this?
    One I'm using right now is:
    s.replaceAll("[^\\x00-\\x7F]", "");//s is a string having chinese characters.
    I'm looking for a standard Solution for such problems, where we deal with multiple lingual characters.
    TIA
    Nitin

    Nitin_tiwari wrote:
    I have a string which has Chinese as well as Japanese characters, and I only want to remove only Chinese characters.
    What's the best way to go about it?Oh, I see!
    Well, the problem here is that Strings don't have any information on the language. What you can get out of a String (provided you have the necessary data from the Unicode standard) is the script that is used.
    A script can be used for multiple languages (for example English and German use mostly the same script, even if there are a few characters that are only used in German).
    A language can use multiple scripts (for example Japanese uses Kanji, Hiragana and Katakana).
    And if I remember correctly, then Japanese and Chinese texts share some characters on the Unicode plane (I might be wrong, 'though, since I speak/write neither of those languages).
    These two facts make these kinds of detections hard to do. In some cases they are easy (separating latin-script texts from anything else) in others it may be much tougher or even impossible (Chinese/Japanese).

  • Retreiving number and characters from string

    Hello fellow developers,
    Lets say i have the following string ER686 and want to split the string into a number and characterpart resulting in a String "ER" and an int "686". What is the best approach to accomplish this?
    Thank you for any help offered.

    The format is that there's a sequence of strings 2 or
    3 and a squence of numbers 3 or 4You might use a Pattern matcher, using a regular expression like the following :"(\\D{2,3})(\\d{3,4})"This expressions represents "two or three non-digit characters followed by 3 or 4 digits". The parenthesis are here to allow getting the two elements (groups) separately.
    Use the find() method of the matcher, then retrieve the two groups with group(1) and group(2).
    Eventually, parse the latter if required.

  • Return selected number of characters from a string

    How do you select a certain number of charaters from a string?
    For example:
    I have a string that contains 51-108
    I want to separate the string into two strings one containing 51 and another one containing 108.

    A StringTokenizer will do it.
    StringTokenizer strtok = new StringTokenizer(yourString, "-");

  • How can i remove the special characters from my keyboard on my iphone3gs

    how can i remove the special character from my keybord keys on my iphone 3gs

    What characters are you talking about exactly and why would you want to remove any?
    There is really no way to modify Apple's keyboards or add your own in iOS, but there are some apps that may provide a work around.

  • Removing non-English characters from data.

    Ours is global system with some data with non-English characters. We want to download file by removing this non-English characters.
    Any suggestions how we can remove these non-English characters from file..?

    The FM u said
         Replace non-standard characters with standard characters
       Functionality
         SCP_REPLACE_STRANGE_CHARS processes a text so that it only contains
         simple characters. Special characters and national characters are
         replaced in such a way that the text remains reasonably legible.
         The character set 1146 is used by default. In this case the following
         replacements are made, for example:
          Æ ==> AE        (AE)
          Â ==> A         (Acircumflex)
          Ä ==> Ae        (Adieresis)
          £ ==> L         (sterling)
         Note that the new text can be longer than the old.
    So i dont think it ll be useful for eliminating the sp. chars.
    U have to check each and every alphabet with std 26 alphabets
    Thanks & Regards
    vinsee

Maybe you are looking for

  • Best way to read data sources in parallel

    Hi, I'm looking for conceptual help as I start a project. I am trying to figure out the best way to get data from several sources at different timings and deliver them to a main vi. I have 4 systems, which each work well on their own (OK, one doesn't

  • Message on mac pro

    Hi, I want to sep up Message on my mac pro, version (Mac OS X version 10.7.5), in sync with imessage on the iphone. However, I can't find the Message program on the Mac pro. I'm wonderring if I should download one from somewhere (I can't find the lin

  • Nokia Maps subscription info lost after firmware u...

    anyone tell me why my maps software has lost the subscription data for navigation - only 10 months used, lost after recent firmware update- dont want to pay again but it keeps asking me to when I want to navigate

  • Manual calculation of 'Buffer Cache hit ratio'

    Using: Oracle 10.2.0.1.0, Redhat 4, 64bit. Manual calculation of 'Buffer Cache hit ratio' is very off from what it shown in statspack. Statspack shows: Instance Efficiency Percentages ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~             Buffer Nowait %:  100.

  • I would like to use FireWire to move files between 2 iBook G3's.

    I would like to use FireWire to move files between 2 iBook G3's but the disk icon for the target disk computer does not show on the other. I've tried using 3 different iBooks and 2 different Firewire cables. Are there any other settings I should use?