Ignoring spaces and non-alphanumeric characters

I need some help with this program im working on. It's testing to see whether words are palindromes or not. The trouble is, i need to make the program ignore spaces and puncuation. Does anyone know of a command to do this, or a command where i can list all the common types of puncuation and get the program to ignore them.
Thanks

you can use regular expressions (regex) for this. I'm not very experienced with regex (though I admit I should become familiar with it ;)), so for more information check out Sun's regex tutorial and regular-expressions.info.
if you're not interested in regex (or if you don't have access to a 1.4+ SDK), you can just use ASCII filtering to achieve this (see this ASCII table for basic ASCII values). Basically, you're only going to accept A-Z and 0-9 characters (if I understand your question correctly). This means the only ASCII values you want to accept is 48-57, 65-90, and 97-122. You can use a simple boolean method to check if a character is valid. Something like this should work:
public boolean valid(char c) {
     int x = (int)c; // ascii value of c
     return ((x >= 48 && x <= 57) || (x >= 65 && x <= 90) || (x >= 97 && x <= 122));
}Use this method on every character of the String you want to process. So to validate an entire String you can use a method like this:
public boolean valid(String s) {
     for (int j = 0;j < s.length();j++) {
          if (!valid(s.charAt(j))) {
               return false;
     return true;
}Beware though that this is considerably slower than using regular expressions. Also I didn't compile this example so there might be a small mistake you'll have to fix.

Similar Messages

  • Validation for Unique Name and Non-AlphaNumeric Characters

    Hi All,
    How to do Unique name and Non-Alpha Numeric Characters Validation?
    Name should be unique and only allow alphanumeric characters.
    Where all validations must be done? In EOImpl or any other file?
    Plz help
    Thanks,
    Sk

    SK
    Here are the steps you need to perform to check duplicate Employee Names need not entered by user.
    First create a VVO in your schema.server package(that of EO) with the following query.Generate both VVOImpl and VVORowImpl file.
    select full_name
    from fwk_tbx_employees
    where full_name =:1Now add this VVO to your VAM means give instance to it.
    Now open the VVOImpl and write below code to execute query based on new name entered by user
        public void initQuery(String name)
          setWhereClauseParams(null); // Always reset
          setWhereClauseParam(0, name);
          executeQuery();
        }Now open Your Entity Expert class and add below method in it
       public boolean isEmployeeNameExists(String name)
         boolean isExists = false;
               // Note that we want to use a cached, declaratively defined VO instead of creating
               // one from a SQL statement which is far less performant.
         EmployeeNameVVOImpl employeeNameVVO =
           (EmployeeNameVVOImpl)findValidationViewObject("EmployeeNameVVO1");
         employeeNameVVO.initQuery(name);
         // We're just doing a simple existance check.  If we don't find a match, return false.
         if (employeeNameVVO.hasNext())
           isExists = true;
         return isExists;
       }Now you need to call this expert class method from setter method of EOImpl for name.so Open your EOImpl file and go to setter method of name
          if ((value != null) || (!("".equals(value.trim()))))
            EmployeeEntityExpert expert = getEmployeeEntityExpert(getOADBTransaction());
            if (!(expert.isEmployeeNameExists(value)))
                throw new OAException("Duplicate Employee Name", OAException.ERROR);
          }Remember to write code above setAttributeInternal.
    Hope it helps!!!!
    Let me know if you have queries in it.
    Thanks
    AJ

  • Why doesn't the quality meter approve of any of my choices of master passwords, no matter how I mix both letters, digits and non-alphanumeric characters?

    I tried to create a master password, but it couldn't be done 'cause the quality meter never accepted any of my passwords, even though I used a very complicated mix of letters, digits and special characters as well.

    There are no requirements when setting Firefox's master password. The password quality meter is purely informative.
    If you're trying to fill the bar all the way, that's unlikely unless you create a lengthy password, or a very complex mix of special characters, digits and lowercase and uppercase letters. Keep in mind the master password should be easily remembered and typed in, time after a time. A highly secure password that is easily mistyped or forgotten is of no use.

  • 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

  • Non-alphanumeric characters part of a word?

    Hi,
    When searching using "23" the users have complained that it brings back terms like 23:00 and www.bob.....html?q=23. It's a bit of a long stretch but is there anyway to disregards those item.
    I expect I'll probably end up explaining to the users that non-alphanumeric characters are regarded in the same was as white spaces, but is this a general standard, and is there a link to more information anywhere?
    Cheers

    You could make your colon and equal sign printjoins or skipjoins.

  • Non-alphanumeric characters in textarea causing 404 errors

    I'm only just becoming acquainted with Coldfusion, as I've been asked to fix a problem in an existing system. The system consists of a simple html form containing a text area, among other input fields. The form is submitted to a cfm script, which displays a confirmation page and sends a couple of emails. The problem is that whenever the user enters any (as far as I can tell) non-alphanumeric characters, e.g. quotes, commas or brackets, in the textarea field, they get a 404 response from the server.
    I tried a number of things to identify the problem, including escaping the text in javascript before submission, but didn't get anywhere. The last thing I tried was installing a local version of the CF on my workstation, hoping to reproduce the problem and thus debug it more easily. However, on my local CF setup the problem does not occur.
    Can anyone help me debug this please? Thanks,
    Marcin

    Thanks for your response. The form method is "post". The only thing that the CFM handler does with this field (gametestexperience) is include it at the bottom of an email message:
    <CFMAIL TO="[email protected]"
    FROM="#email#"
    SUBJECT="Tester Application"
    type="html"
    server = "Cluster9.us.messagelabs.com">
      Automatically logged from the internet form:<p><p>
    <table>
    <tr><td>EmailFrom</td><td>#email#</td>
    <tr><td>From</td><td>#firstName# #lastName#</td></tr>
    <tr><td>Sent</td><td>#DateFormat(Now())#</td></tr>
    <tr><td>Referrer</td><td>#referer#</td></tr>
    <tr><td>Confirmation</td><td>#agree1#, #agree2#, #agree3#, #agree4#, #agree5#</td></tr>
    <tr><td>FamilyCompetitor</td><td>#familycompetitor#</td></tr>
    <tr><td>FamilyWork</td><td>#familywork#</td></tr>
    <tr><td>ReferredBy</td><td>#referredBy#</td></tr>
    <tr><td>RefererDetails</td><td>#refererdetails#</td></tr>
    <tr><td>FirstName</td><td>#firstName#</td></tr>
    <tr><td>LastName</td><td>#lastName#</td></tr>
    <tr><td>Email</td><td>#email#</td></tr>
    <tr><td>TelephoneHome</td><td>#telephoneHome#</td></tr>
    <tr><td>TelephoneCell</td><td>#telephoneCell#</td></tr>
    <tr><td>TelephoneDay</td><td>#telephoneDay#</td></tr>
    <tr><td>City</td><td>#homeTown#</td></tr>
    <tr><td>Employment</td><td>#employment#</td></tr>
    <tr><td>GamerType</td><td>#gamerType#</td></tr>
    <tr><td>GamerStyle</td><td>#gamerStyle#</td></tr>
    <tr><td>HoursPerWeek</td><td>#hoursPerWeek#</td></tr>
    <tr><td>PreferredGenres</td><td>#preferredGenres#</td></tr>
    <tr><td>Consoles</td><td>#console#</td></tr>
    <tr><td>GamesPlayed</td><td>#gameplayed#</td></tr>
    <tr><td>Available</td><td>#available#</td></tr>
    <tr><td>TestedBefore</td><td>#testedBefore#</td></tr>
    <tr><td>TestingExperience</td><td>#gametestexperience#</td></tr>
    </table>
      Thanks,<P>
      Focus Test Team!<P>
    </CFMAIL>

  • [solved] Non-alphanumeric characters broken in TinyChat

    Hello, fellow archers.
    I've been having a bit of trouble with the TinyChat site. Most non-alphanumeric characters are being displayed as crossed-out boxes. This problem is exclusive to TinyChat and has not occured in any other Flash applications.
    An example of the broken characters:
    Note how the / and > characters are not broken.
    This is the second installation of ArchLinux on my computer, the problem occured on the current install only. I suspect the problem is caused by a missing package, though the only hint I was able to find was installing the ttf-ms-fonts package (https://wiki.archlinux.org/index.php/br … ash_Player). This did not resolve the issue.
    Package versions:
    firefox 34.0.5-1
    flashplugin 11.2.202.425-1
    I'll gladly provide any other information that could help resolve this issue.
    Last edited by skoftoby (2015-01-21 18:31:26)

    Head_on_a_Stick wrote:
    skoftoby wrote:I'd like to request this topic be marked as solved either way.
    As with most things Arch, you have to do this yourself -- edit the title of your first post & put "[SOLVED]" at the beginning.
    Whops. The subject length was exactly at the maximum length, and since I couldn't edit the title any further, I thought a moderator had to edit it. Apologies!

  • How to support non alphanumeric characters when using WORLD_LEXER?

    BASIC_LEXER has an attribute of printjoins which we can specify the non alphanumberic characters as normal alphanumberic in query and included with the token. However, WORLD_LEXER doesn't have this attribute. So in order to use some non alphanumberic characters and treat them as alphanumberic characters in Oracle Text Index, such as ><$, what should I can?
    Thanks in advance for any help.

    I use WORLD_LEXER to create Oracle Text Index to support UTF-8.
    Below is the script to create table and index:
    REM Create table
    CREATE TABLE my_test
    ( id VARCHAR2(32 BYTE) NOT NULL,
    code VARCHAR2(100 BYTE) NOT NULL,
         CONSTRAINT "my_test_pk" PRIMARY KEY ("id"));
    REM create index
    exec ctx_ddl.create_preference('stars_lexer','WORLD_LEXER');
    exec ctx_ddl.create_preference('stars_wordlist', 'BASIC_WORDLIST');
    exec ctx_ddl.set_attribute('stars_wordlist','substring_index','TRUE');
    exec ctx_ddl.set_attribute('stars_wordlist','PREFIX_INDEX','TRUE');
    -- create index for Table corrosion level
    CREATE INDEX my_test_index
    ON my_test(code)
    INDEXTYPE IS CTXSYS.CONTEXT
    PARAMETERS ('LEXER stars_lexer STOPLIST stars_stop WORDLIST stars_wordlist SYNC(EVERY "SYSDATE+5/1440") TRANSACTIONAL');
    INSERT INTO my_test('1', 'English word1');
    INSERT INTO my_test('2', '违违');
    INSERT INTO my_test('3', '违违&^|违违');
    When I query:
    select * from corrosion_levels r where contains(r.CORROSION_LEVEL, '{%违${|违%}') > 0
    ID CODE
    3 违违$(|违违
    2 违违
    Actually, the result what I want is: 3 违违$(|违违
    So the requirement is that all non-alphanumeric characters should be treated as normal alphanumeric charcters. Please tell me how to implement it.

  • SQL*Loader-350: Illegal combination of non-alphanumeric characters

    Hi all,
    how to skip a column in control file.
    i.e.
    I have a table with 10 columns and FAT file contains 11 columns.
    how to skip a last column ?
    and
    I added extra column to Table and I changed the control file too.
    but i am getting error.
    SQL*Loader-350: Syntax error at line 115.
    Illegal combination of non-alphanumeric characters
    thanks in Advance.

    Tom Kyte has an elaborate solution on his page:
    http://osi.oracle.com/~tkyte/SkipCols/index.html
    Or post the table description and the control file, so we can have a look at it.

  • Hot to set the Non-alphanumeric characters attribute?

    Hello,
    I'm developing an asp.net application using the oracle membership provider. I have installed the databse objects in an Oracle 9i and when I try to create a new user, It always asks me to consider at least 1 Non-alphanumeric character in the password, even if I put in the web.config file the minRequiredNonalphanumericCharacters="0" attribute. Is there another way to set the Non-alphanumeric characters to "0".
    Thanks.

    Workaround: set 0 for minRequiredNonalphanumericCharacters attribute in your machine.config for OracleMembershipProvider. The defalt value is 1. The typical location of machine.config is in %windir%\Microsoft.NET\Framework\v2.0.50727\CONFIG.

  • Account Codes with non Alphanumeric characters

    I have a customer who has Business Partner Codes which contain non Alphanumeric characters :
    space
    full stop
    apostrophe
    forward slash
    hyphen
    Will this cause issues with the operation of any aspect of Webtools - what if anything should I watch out for since these cannot be changed?

    Thanks for your response. The form method is "post". The only thing that the CFM handler does with this field (gametestexperience) is include it at the bottom of an email message:
    <CFMAIL TO="[email protected]"
    FROM="#email#"
    SUBJECT="Tester Application"
    type="html"
    server = "Cluster9.us.messagelabs.com">
      Automatically logged from the internet form:<p><p>
    <table>
    <tr><td>EmailFrom</td><td>#email#</td>
    <tr><td>From</td><td>#firstName# #lastName#</td></tr>
    <tr><td>Sent</td><td>#DateFormat(Now())#</td></tr>
    <tr><td>Referrer</td><td>#referer#</td></tr>
    <tr><td>Confirmation</td><td>#agree1#, #agree2#, #agree3#, #agree4#, #agree5#</td></tr>
    <tr><td>FamilyCompetitor</td><td>#familycompetitor#</td></tr>
    <tr><td>FamilyWork</td><td>#familywork#</td></tr>
    <tr><td>ReferredBy</td><td>#referredBy#</td></tr>
    <tr><td>RefererDetails</td><td>#refererdetails#</td></tr>
    <tr><td>FirstName</td><td>#firstName#</td></tr>
    <tr><td>LastName</td><td>#lastName#</td></tr>
    <tr><td>Email</td><td>#email#</td></tr>
    <tr><td>TelephoneHome</td><td>#telephoneHome#</td></tr>
    <tr><td>TelephoneCell</td><td>#telephoneCell#</td></tr>
    <tr><td>TelephoneDay</td><td>#telephoneDay#</td></tr>
    <tr><td>City</td><td>#homeTown#</td></tr>
    <tr><td>Employment</td><td>#employment#</td></tr>
    <tr><td>GamerType</td><td>#gamerType#</td></tr>
    <tr><td>GamerStyle</td><td>#gamerStyle#</td></tr>
    <tr><td>HoursPerWeek</td><td>#hoursPerWeek#</td></tr>
    <tr><td>PreferredGenres</td><td>#preferredGenres#</td></tr>
    <tr><td>Consoles</td><td>#console#</td></tr>
    <tr><td>GamesPlayed</td><td>#gameplayed#</td></tr>
    <tr><td>Available</td><td>#available#</td></tr>
    <tr><td>TestedBefore</td><td>#testedBefore#</td></tr>
    <tr><td>TestingExperience</td><td>#gametestexperience#</td></tr>
    </table>
      Thanks,<P>
      Focus Test Team!<P>
    </CFMAIL>

  • Validation for Non-AlphaNumeric characters

    Hi All,
    I want to do Validation for Non-Alpha Numeric characters.
    While saving record, Name should only allow alphanumeric(letters and numbers only) characters, No special characters.
    How to do this?
    Plz help
    Thanks,
    Sk

    SK
    In EOImpl file in setter method of Name you can write below logic
    import java.util.regex.*;
      public void setLastName(String value)
        Pattern p = Pattern.compile("[^a-zA-Z0-9]");
        Matcher m  = p.matcher(value);
            if (m.find()){
                System.out.println("last Name"+value);
                throw new OAException("Special Characters Not allowed in Name", OAException.ERROR);
           setAttributeInternal(LASTNAME, value);
      } Hope it helps!!!!
    Thanks
    AJ

  • Why does Acrobat allocate more width for spaces than for alphanumeric characters?

    When I convert a text file to PDF using Acrobat X Pro, I select a fixed-width font.  However, it appears that Acrobat allocates a greater width for space characters in the text file, than it does for alphanumeric characters in the text file.  How do I instruct Acrobat to use exactly the same width for all the characters, both spaces and visible characters?
    This question is actually a re-write of my previous post titled, ‘Bulk Convert Text to PDF with Acrobat’.  I know what the problem is now but do not how to fix it.
    Here's a mock example of the content of a text file.  In the resulting PDF, the H no longer lies directly under the G.  I chose Courier New 8 pt for the font.
        ABCDEFG    ABCDEFG    ABCDEFG    ABCDEFG    ABCDEFG    ABCDEFG
              H          H          H          H          H          H
    Any suggestion will be appreciated.  Thank you.

    If you are comfortable with the settings in the printing, then go back to the PDF Maker settings (create PDF preferences in WORD) and adjust the preferences for similar performance, at least in the job settings and such. The rest deals with how much you want the bookmarks and such.
    I am assuming that those PDF Maker preferences set in WORD are retained when you run the conversion from Acrobat that I have the impression you are doing. Other than that, check the conversion settings in Acrobat itself. They are in the preferences. If you the printer preferences are used when converting from Text (you will have to try to see what happens), it would use the default preferences of the printer, not those set in the print menu of an application. The latter only last as long as that application is open and only for that application. For your need, you may need to change them in either the printer (Start>Printers.. in windows) or Distiller, or both. The printer overrides the Distiller settings usually (another setting on this).

  • Why do imported non-alphanumeric characters get corrupted ?

    (I asked this ages ago and it never got solved so I'm having another go).
    When I import tracks to iTunes that I have titled myself (i.e. not from CDs or downloads), characters that are non-alphanumeric (e.g. " ? !) get corrupted to a _ on import.
    Why is this bug occurring? (It's been around since iTunes 6 at least) and how do I stop it?

    Look in Library/Fonts and yourusername/Library/Fonts for instances of the Lucida Grande font.
    Some applications install their own version of Lucida Grande causing conflicts with the Apple version, which is installed with Mac OS X and resides in: System/Library/Fonts.
    Because Lucida is used to display text in Mac OS X menus, buttons and the library lists of iTunes, they can get messed up as a result.
    One particular app - and I would dearly like to know which one, changes the text in iTunes to Hebrew letters. Lots of posts here about that one.
    Message was edited by: Nick Holmes

  • Flex, xml, and non-English characters

    Hello! I have a Flex web app with AdvancedDataGrid. And I use httpService component to load some data to grid. The .xml file contains non-english characters in attributes (russian in my case) like this:
    <?xml version="1.0" encoding="utf-8" ?>
       <Autoparts>
        <autopart  DESCRIPTION="Барабан">
    </Autoparts>
    And when i run app, AdvancedDataGrid display it like "Ñ&#129;ПÐ". How can i fix it? I try to change encoding="utf-8" with some another charsets, bun unsuccesfully. Thank you.

    Try changing the xml structure by using CDATA instead of having the russian part as an attribute and see if that makes any difference.
    What I meant is use something like this:
    <?xml version="1.0" encoding="utf-8" ?>
       <Autoparts>
        <autopart>
           <description><![CDATA[Барабан]]></description>
      </autopart>
    </Autoparts>
    instead of the current xml.

Maybe you are looking for

  • Adobe Setup has stopped working

    "Adobe Setup has stopped working" Everytime I try to run Adobe installer or uninstaller the setup crashes! video example: http://www.screencast-o-matic.com/watch/cjXUiIntb

  • Can't capture anymore

    I just finished a project. I saved It on an external drive, and erase everything related to this project from FCE folder and the library . I was ready to capture from my camera datas for my next project. When I open FCE, the loading of the program st

  • Exclude selection parameters in infopackage

    Hi guys! I've been asked to create an InfoPackage to extract "all product types except <specific type>". If I were in an R/3 Abap Report, it would be easily achieven by passing an 'E' in the "sign" field of the corresponding select-option. But since

  • Can anyone help me to transfer video to iTunes!!

    I have problem to transfer video to iTunes..when i tried to transfer but the movies collumn is nothing..the was not transfer

  • Port no. for IDOC..??

    hello all.. im makin a scenario of FTP to IDOC and when mentioning the port no. of IDOC..where do i get that from...??? regards.. vishal