Deleting/replacing non-alphabetic characters

I'd like to delete any non-anlphabetic characters in a given string, so I figured the following:
for (int i=0; i < aString.length(); i++){          
                    if (!isAlpha(aString.charAt(i))){
                         char c = aString.charAt(i);
                         aString = aString.replace(c,' ');
          }Which doesn't work, and I don't understand why. (Ideally like to delete this char c, but replacing it with whitespace will I think also do)
Anyone any suggestions?

how about using regular expressions?
Here is an example using posix notation:
public class Repl
    public static void main(String args[]){
        String a = "Aghewuz2nknl7kj%\"dsk";
        // here any non alpha char is replaced by a space
        System.out.println(a.replaceAll("[^\\p{Alpha}]", " "));
}{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Playlists containing songs with titles starting with non-alphabetical characters do not get transferred at all

    I was really happy about how the desktop manager lets me choose the songs from my itunes library by playlists! this is smart! I'm also happy to see the playbook render asian characters properly (unlike my experience on the bold!)
    However, I have a lot of songs which have titles that begin with non-alphabetical characters, ie asian characters. For all playlists which contains such songs, those songs do not get transferred onto the playbook AT ALL. For example, I have one playlist which contains only songs with titles beginning with asian characters - this playlist was transferred but it is shown as containing zero songs! When I browse my song library by artist/album, I can find all those songs that should be in that/those playlists.
    Can this be fixed?
    thanks.
    Solved!
    Go to Solution.

    as it turns out, it kind of got fixed by itself. what i did (i think, since i have not definitively verified) was i went to browse "all songs" wherein i noticed all thoses songs starting with asian characters seemed to show correctly. then i went back to the playlists in question, and viola!
    clearly there is a bug or two in the music player somewhere regarding these title characters. but rim has more urgent things to resolve i guess - like my auto screen lock is still not working!

  • Replacing non-ASCII characters with HTML charcter references

    Hi All,
    In Oracle 10g or greater is there a built-in function that will convert a string with non-ASCII characters like this
    a b č 뮼
    into an ASCII string with HTML character references like this?
    a b & # x 0 1 0 D ; & # x B B B C ;
    (note I had to include spaces between each character in the sample code for message to prevent the forum software from converting my text)
    I tried using
    utl_i18n.escape_reference( val, 'us7ascii' )
    but for some reason it returns
    a b c & # x B B B C ;
    Note how it converted the Western European character "č" to its unaccented counterpart "c", not "& # x 0 1 0 D ;" (is this a bug?).
    I also tried a custom solution using regexp_replace and asciistr (which I can't include here because the forum software chokes on it) but it only returns the correct result for values <=4000 characters long. Unfortunately asciistr doesn't appear to accept CLOB values larger than 4000 characters. It returns an error message like
    (ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: 30251, maximum: 4000) ).
    I'm looking for a solution that works on CLOB data of any size.
    Thanks in advance for any insight you can provide.
    Joe Fuda

    So with that (UTF8) in mind, let's take another look.....
    As shown below, I used a AL32UTF8 database.
    Note: I did not use a unicode capable tool for querying. So I set console mode code page to 1250 just to have č displayed properly (instead of posing as an è).
    Also, as a result of using windows-1250 for client character set, in the val column and in the second select's ncr column (iso8859-1), è (00e8) has been replaced with e through character set conversion going from server back to client.
    Running the same code on a database with a db character set such as we8mswin1252, that doesn't define the č (latin small c with caron) character, would yield results with a c in the ncr column.
    C:\>chcp 1250
    Aktuell teckentabell: 1250
    C:\>set nls_lang=.ee8mswin1250
    C:\>sqlplus test/test
    SQL*Plus: Release 11.1.0.6.0 - Production on Fri May 23 21:25:29 2008
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    With the OLAP option
    SQL> select * from nls_database_parameters where parameter like '%CHARACTERSET';
    PARAMETER              VALUE
    NLS_CHARACTERSET       AL32UTF8
    NLS_NCHAR_CHARACTERSET AL16UTF16
    SQL> select unistr('\010d \00e8') val, utl_i18n.escape_reference(unistr('\010d \00e8'),'us7ascii') NCR from dual;
    VAL  NCR
    č e  c e
    SQL> select unistr('\010d \00e8') val, utl_i18n.escape_reference(unistr('\010d \00e8'),'we8iso8859p1') NCR from dual;
    VAL  NCR
    č e  &# x10d; e     <- "è"
    SQL> select unistr('\010d \00e8') val, utl_i18n.escape_reference(unistr('\010d \00e8'),'ee8iso8859p2') NCR from dual;
    VAL  NCR
    č e  č &# xe8;
    SQL> select unistr('\010d \00e8') val, utl_i18n.escape_reference(unistr('\010d \00e8'),'cl8iso8859p5') NCR from dual;
    VAL  NCR
    č e  &# x10d; &# xe8;In the US7ASCII case, where it should be possible for all non-ascii characters to be escaped, it seems as if the actual escape step is skipped over.
    Hope this helps to understand whether utl_i8n is usable or not in your case.
    Message was edited by:
    orafad
    Fixed replaced character references :)

  • Replace non-english characters function

    Hi folks,
    I have a text which includes non english characters. Is there any trick, how can I replace those characters with "closest" english character?
    Examples:
    "Hytölä"  to become "Hytola"
    "Säynatsälo" to become "Säynatsälo"
    etc ...
    I was thinking about usage of REGEXP
    select regexp_replace('Hytölä Säynatsälo ', '[^0-9A-Za-z]', '') from dual
    but a pattern is not correct.
    Any suggesitons?

    There is something that smells like a hack for me (source: replace characters with accent with their base letter)
    However
    with data as (
    select 'Hytölä' str from dual
    union all
    select 'Säynatsälo' from dual
    select
      str
    ,utl_raw.cast_to_varchar2(nlssort(str, 'NLS_SORT=BINARY_AI')) nstr
    ,length(utl_raw.cast_to_varchar2(nlssort(str, 'NLS_SORT=BINARY_AI'))) l
    from data
    STR
    NSTR
    L
    Hytölä
    hytola
    7
    Säynatsälo
    saynatsalo
    11
    Notice that change in length through an extra null bit at the end of the strings.
    And the loss of the uppercase.
    For this kind of questions it's helpful to know about the requirements. Why there shuóuld be a baseletter conversion? For search purposes for example.
    not to forget the db characterset.

  • Replacing non-ascii characters in String

    I have a site where the user enters data in a rich text
    editor (ktml4) that gets stored into a database (mysql). There are
    non ascii characters getting into the data, I'm assuming that they
    are copying and pasting from Word. Unfortunately in this situation,
    changing that process isn't an option.
    Currently, this is the only character that is causing me
    problems:
    http://www.zvon.org/other/charSearch/PHP/search.php?request=ffa0&searchType=3
    I would just like to replace the non-ascii characters with a
    space when I read them from the database. Something like:
    #Replace(result.column, '\xffa0', ' ')#
    However, I believe that code looks for the string "\xffa0",
    not the character \xffa0.
    Is there anyway to do this?

    quote:
    Originally posted by:
    BuckLemke
    quote:
    Originally posted by:
    Dan Bracuk
    rereplace might work.
    Can you give an example of how to pass a non-ascii character
    to REReplace?
    Regular expressions are not my strength, but the approach I
    was considering was, "if it's not an ascii character, make it a
    space". Then you pass the entire string at once.

  • Replace Non-Numeric Characters with a Numeric Character in a String

    Hi Guys,
    I need to replace all the non-numeric characters (including embedded blanks & hyphen) in a string to a numeric character '1'.
    The trailing blanks should not be replaced.
    e.g. "P22233344455566" should be changed to "122233344455566"
    &    "49-1234567           " should be changed to "4911234567          "
    Please help.

    Use [replace|http://help.sap.com/abapdocu_70/en/ABAPREPLACE_IN_PATTERN.htm] with a regular expression to translate any non-numeric character (i.e. any character not between 0 and 9) to 1:
      REPLACE ALL OCCURENCES OF REGEX '[^0-9]' IN value WITH '1'.
    Cheers, harald
    p.s.: In older releases [translate|http://help.sap.com/abapdocu_70/en/ABAPTRANSLATE.htm] would also do the trick, but is more lengthy, because one would need to specify each individual character that should be replaced, e.g.:
      TRANSLATE value TO UPPER CASE.
      TRANSLATE value USING
          ' 1_1-1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1'.

  • Replacing non latin characters

    Hi experts,
    i have to check some fields of non latin characters.
    When the fields include some of non latin charcters I have to replace them
    with an "Y".
    Have somesone a code example for this case?
    Thanks for help!
    Alex

    This should give you an Idea 
    WHILE p_faxno CA sy-abcde.  " to check if varaible contains any abcde...Z
        p_faxno+sy-fdpos(1) = 'Y'.
      ENDWHILE.
      CONDENSE p_faxno NO-GAPS

  • RegEx in TSQL - replace non-alphanumeric characters etc

    Hi guys, I have this function in VB that I used in Access to replace all non-alphanumeric characters, including spaces and anything in brackets.
    Public Function charactersonly(inputString As String) As String
    Dim RE As Object
    Set RE = CreateObject("vbscript.regexp")
    RE.Pattern = "\([^)]+\)|[^\w]|_"
    RE.Global = True
    charactersonly = RE.Replace(inputString, "")
    Set RE = Nothing
    End Function
    Now, I moved to SQL server and I'm writing scripts to do same thing.
    How can I use RegEx in TSQL?
    Only thing I will do is that function.

    As alternative
    declare @string varchar(200)
    set @string = 'gg$%^^&is%^& s2342jjk23&&({}e c76l232e+_+a#n/ c][#o''y#e'
    select cast(cast((select substring(@string,n,1)
    from numbers
    where n <= len(@string)
    and substring(@string,n,1) like '[0-9 ]' for xml path('')) as xml)as varchar(max))
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How to replace non-alphanumeric characters with " "  in a String?

    Hi,
    Anyone can help with this?
    I guess I should use the replaceAll-method??

    I need to keep characters that are generally ok to
    use in
    sentences, like ".", ",", "!", and "-" and alsoall
    digits and letters
    (numbers and alphabetic characters).Add those characters to the pattern in that case. Add
    them just before ]
    but placing the '-' char as the last in the list.

  • Select Query to fetch rows that contain non alphabetic characters

    how to select rows from a table (tab1) where a specific column (tab1.col1) has non alphabetic characters

    hi,
    you didnt specify which version you are using.
    if you are working on oracle 10g you can use regular expressions like this:
    select * from tab1 where regexp_like(col1,'[^[[:alpha:]]]');

  • Replace non ascii characters

    I have a person that is called "josée".
    I need "JOSEE" to be inserted into the database, not "JOSéE".
    I also have a person called "jürgen".
    I need "JURGEN" to be inserted into the database.
    Is there a way to do this ?
    (replace the non-ascii character by his corresponding ascii character)

    Thanks ebrian, I tried your suggestion:
    SELECT VALUE, REGEXP_REPLACE(VALUE, '^[:ascii:]') FROM AUDIT_TAB_COLUMNS WHERE VALUE = '' ;
    It sill leaves in the square unfortuneatly.
    Dave

  • Replace non numerics characters with 0

    Hi,
    Can someone help me out with this?
    I basically need to check my column value.
    In case thr is an occurence of any non numeric character ,I need to replcae it with a 0.
    By non numeric I mean any character other than [0-9].
    For example 'rte$36^r'
    I would like to convert it o '00003600'.
    Thanks in advance.

    There are several options, like TRANSLATE or REGEXP_REPLACE (only 10g):
    WITH t AS (SELECT 'rte$36^r' col1
                 FROM dual
    SELECT t.col1
         , REGEXP_REPLACE(t.col1, '[^0-9]', '0') col1_new1
         , TRANSLATE(t.col1, '0123456789' || t.col1, '0123456789' || LPAD('0', LENGTH(t.col1), '0')) col1_new2
      FROM t
    COL1     COL1_NEW1            COL1_NEW2
    rte$36^r 00003600             00003600C.

  • Version 6.0 running under Win 7 - non-alphabetic characters typed appear as something other than what I typed -- É for question mark for example.

    Forward slash appears as lower case e-acute é, question mark as upper-case É. Some, not all shifted numerals also map differently. Shift-3 for instance is forward slash instead of hash symbol.
    I played around with character sets - various unicode and western sets - this resolved the problem in an earlier FF version, even after I`d reverted to what I started out with ( I can`t even remember what the default is now.) It was also suggested elsewhere in this forum that the problem could be resolved using the Region and Language settings in Windows Control Panel. This is obviously wrong, because the keyboard is working fine in other applications. It was also suggested I try to resolve by activating the language toolbar in the taskbar, but the option doesn`t even show up so I assume it was never installed.
    My judgement this problem is definitely not OS, but Firefox.

    See:
    * http://support.microsoft.com/kb/306993 - HOW TO: Use the Language Bar in Windows XP
    * http://windows.microsoft.com/en-US/windows-vista/The-Language-bar-overview - The Language bar (overview)
    * http://windows.microsoft.com/en-US/windows7/The-Language-bar-overview The Language bar (overview)
    It is possible that you have switched the keyboard layout by accident.<br />
    Windows remembers that setting per application.
    * Make sure that you have the Language bar visible on the Windows Taskbar.
    * You can do that via the right-click context menu of the Taskbar: Toolbars > Language Bar.
    * Check the keyboard language (keyboard layout) setting for the application that has focus via the icon on the Language bar.
    * You need to do that while Firefox has focus because Windows remembers the keyboard layout setting per application.
    * The default keys to rotate the layout is a combination (Ctrl+Shift or Alt+Shift) that can easily be used in Firefox to activate a menu item.
    * To avoid an unintentional switch assign a specific key sequence (Alt/Ctrl+Shift+number) to select keyboard layouts and remove the key combination to rotate layouts (Alt+Shift or Ctrl+Shift)
    * Control Panel > Regional and Language Options > Keyboards and Languages > Change keyboards > Advanced key settings > Change key sequence

  • 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

  • Download none-English characters from tables

    Hi guys,
    I use apex 4.1.1 multilingual - with oracle xe 11g R2.. with listener 1.1.3 deployed on Glassfish 3.1.1
    I have Arabic data stored in my tables. if I go to Object Browser and try to download it, I get question marks instead of the letters....
    I have the same problem if I want to download the data of IR...
    Can you help please ??
    Regards,
    Fateh

    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

  • Wireless issues with MacBook Pro i5 in Boot Camp Windows 7 x64

    I have a 2010 Macbook Pro i5 15''. I'm usually connecting to the 802.11n 5Ghz wireless network of my Time Capsule when running OS X, which works absolutely fine. When running Windows 7 x64 in Boot Camp though, this network can't be found and I have t

  • I cant find calendar in outlook express? i have outlook express 2004

    i cant find calendar in outlook express? i have outlook express 2004

  • Void interface

    Hi, I need to trigger a XI interface from R/3 (Abap Proxy) that will trigger a void Stored Procedure. There is any way to do this? ABAP Proxy -> XI Interface -> Stored Procedure There are <b>no field</b> mapping between all parts. Thanks.

  • Why won't iPhone 5c tweet from photo gallery?

    All settings appear to be on. Previous iPhone 4s-the backup of which was used to populate the new 5c-worked fine in this function. I have to go to Twitter and select the photo from there.

  • Are all orders from Apple being shipped from China?

    I ordered my iphone 32gb from apple.com... anyone ordered from apple.. and the phones being shipped from US? Mines is coming from China delivery date of Tuesday ... well actually because im getting mines eventually.