Checking For Characters

How do I test to see if a character at a particular position in the String matches a character in the same position of a different String? How do I also test to see if a character at a particular position is a "e" or any other letter? I've tried looking in the JAVA library, but I can't find what I am looking for.

How do I test to see if a character at a particular
position in the String matches a character in the
same position of a different String? How do I also
test to see if a character at a particular position
is a "e" or any other letter? I've tried looking in
the JAVA library, but I can't find what I am looking
for.
if(my_str1.charAt(pos) == my_str2.charAt(pos) ) {
// do something
switch(my_str1.charAt(particular_pos))
case 'e' : // Something to do with...
break;
case 'a' :  // Something to do with...
break;
default : break;
}

Similar Messages

  • RegEx for characters with accents and such but not alphanum or punctuation

    I'm creating a fuction that checks for the following code snip. I'm having trouble understanding what I need to do to get the last criteria. How do I specifically check for characters with additional marks  such as   a'   but  not  a
    Thanks in advance for any help or advice you might give
        <!---Contain characters from three of the following five categories:--->
                <!---English uppercase characters (A through Z)--->
       <cfif ReFind("[[:upper:]]+",passwd,0, false) gt 0>
        <cfset numCharSets = numCharSets + 1>
       </cfif>
                <!---English lowercase characters (a through z)--->
       <cfif ReFind("[[:lower:]]+",passwd,0, false) gt 0>
        <cfset numCharSets = numCharSets + 1>
       </cfif>
                <!---Base 10 digits (0 through 9)--->
       <cfif ReFind("[[:digit:]]+",passwd,0, false) gt 0>
        <cfset numCharSets = numCharSets + 1>
       </cfif>
                <!---Non-alphabetic characters (for example, !, $, #, %)--->
       <cfif ReFind("[[:punct:]]+",passwd,0, false) gt 0>
        <cfset numCharSets = numCharSets + 1>
       </cfif>
                <!---A catch-all category of any Unicode character that does not fall under the
          previous four categories. This fifth category can be regionally specific.--->

    AWEInCA1 wrote:
    How do I specifically check for characters with additional marks  such as   a'   but  not  a
    By recognizing they are seperate characters.  You will probably want to use codes to access these characters.
    \uFFFF where FFFF are 4 hexadecimal digits
    Matches a specific Unicode code point. Can be used inside character classes.
    \u00E0 matches à encoded as U+00E0 only. \u00A9 matches ©
    http://www.regular-expressions.info/refunicode.html
    http://www.regular-expressions.info/reference.html

  • Regular expression: check for the presence of special characters.

    I have the following requirement:
    I need to check for the presence of the following characters in a keyword: @, #, > if any of these characters are present, then they need to be stripped off, before going further. Please let me know the regular expression to check for these characters.

    I am trying to extend the same logic for the following characters:
    .,‘“?!@#%^&*()-~<>[]{}\+=`©® . here is the code fragment:
    Pattern kValidator = Pattern.compile("[\\.,\\‘\\“?!@#%^&*()-~<>[]{}\\+=\\`©®]");
    Matcher kMatcher = kValidator.matcher(keyWord);
    if (kMatcher.find(0)) {
    keyWord = keyWord.replaceAll("[.,\\‘\\“?!@#%^&*()-~<>[]{}\\+=\\`©®]", " ");
    }I get the following error. This error is from the weblogic command window. I dont understand these special characters.
    Error:
    28 Oct 2008 12:27:48 | INFO  | SearchController   | Exception while fetching search results in controller:Unclosed character class near index
    39
    [\.,\&#915;Çÿ\&#915;Ç£?!@#%^&*()-~<>[]{}\+=\`&#9516;&#8976;&#9516;«]
                                           ^
    java.util.regex.PatternSyntaxException: Unclosed character class near index 39
    [\.,\&#915;Çÿ\&#915;Ç£?!@#%^&*()-~<>[]{}\+=\`&#9516;&#8976;&#9516;«]
                                           ^
            at java.util.regex.Pattern.error(Pattern.java:1650)
            at java.util.regex.Pattern.clazz(Pattern.java:2199)
            at java.util.regex.Pattern.sequence(Pattern.java:1727)
            at java.util.regex.Pattern.expr(Pattern.java:1687)
            at java.util.regex.Pattern.compile(Pattern.java:1397)
            at java.util.regex.Pattern.<init>(Pattern.java:1124)
            at java.util.regex.Pattern.compile(Pattern.java:817)

  • Checking for Special Characters

    I need to check if a textbox in my form containes special characters (entered by user). If there are any, I need to display an error message.
    I have written a function but it's not working.
    here's my function:
    function checkForSpecialChracters(oFiled)
    var userInput = oFiled.rawValue; // take the String entered by the user
    var iChars = "@#$%^&*+=-[]\\\';,./{}|\":<>?~_";
    for (var i = 0; i < userInput.length; i++)
    if (iChars.indexOf(userInput.charAt(i)) != -1) {
    xfa.host.messageBox("Please check for special characters. The following characters are not allowed: @#$%^&*+=-[]\\\';,./{}|\":<>?~_ ", "Error Message", 3);
    // Change the color of the field
    oFiled.fillColor = "255,100,50";
    Any help would be greatly appreciated.
    Thank you!

    Paul,
    It is working now. I don't know what I might have changed.
    Here's my final function (It works!):
    function checkForSpecialChracters(oFiled)
    var userInput = oFiled.rawValue; // take the String entered by the user
    var iChars = "@#$%^&*+=-[]\\\';,./{}|\":<>?~_";
    var hasSpecialCharacter = false;
    for (var i = 0; i < userInput.length; i++)
    //app.alert("Value is: " + userInput.charAt(i));
    if (iChars.indexOf(userInput.charAt(i)) != -1)
    hasSpecialCharacter = true;
    break;
    } // end if
    } // end For loop
    if (hasSpecialCharacter)
    // Change the color of the field
    oFiled.fillColor = "255,100,50";
    xfa.host.messageBox("Please check for special characters. \n\nThe following characters are not allowed:\n\n @#$%^&*+=-[]\\\';,./{}|\":<>?~_ ", "Error Message", 3);
    else if (!hasSpecialCharacter)
    oFiled.fillColor = "255,255,255";

  • Can i check for invalid chars inside characters () method

    Hi There
    Cani check for invalid charcaters inside characters() method of SAX api so as to take care of invalid charactrers that mey come up while parsing an xml file from the internet
    Thanks
    Mum

    Hi DrClap
    Thanks for responding.But i have no control on the encoding of the xml file that is coming to me
    So i will be thankful to u if u could just tell me if there is any way in which i can change the encoding format used for parsing the xml file so my parsing process reaches its logical end
    Thanks
    Mumtaz

  • Check for non-numeric characters in textbox input

    I have a form with several textboxes, each of which can accept numeric input. I want to write a validation/ plsql block that checks for a non-numeric character in the input, so that my user sees a customized error message rather than a database error. Any tips on how I can achieve that? Is there any function like "isalpha" in C, which can directly do the job?
    Also, some of these numeric fields should allow commas, since people put commas in larger numbers.
    Any help is greatly appreciated.

    Arie,
    i figured it out. turns out, i had some confusion in my mind. i modified Taneal's solution to use it in my already existing validations of type 'function returning error text' and it works fine.
    the problem before was that i was running 2 separate validations on the same field, and probably due to the sequence numbers, i was getting a numeric or value error. now, i've combined all validations into a single validation and it works fine.
    and honestly, i'm pretty bad with reg. ex. :D

  • Check special characters in a string

    Hi all
    I am using oracle 10g.......
    Need to know what should be the query to check whether a special character exists or not in a column value....used the following query like.....
    select count(*) into emp_no_count_special_char
    from dual
    where REGEXP_LIKE(insert_data_rec.emp_no , '[#!$^&*%./\|]$' )
    or REGEXP_LIKE(insert_data_rec.emp_no , '^[#!$^&*%./\|]' );
    This works fine in case a string starts or ends with a special character ,what if a string of special characters lies in between numeric digits.
    e.g: '100#$%7'
    Please help find a query that checks for the existence of sp. characters irrespective of their position in the column!!!
    Thanks
    Dave
    Edited by: Dave on Jun 6, 2012 5:17 AM
    Edited by: Dave on Jun 6, 2012 5:18 AM

    Hi Dave,
    example below:
    -- Check that at least one special character exists in the string
    SELECT COUNT (*)
      INTO emp_no_count_special_char
      FROM DUAL
    WHERE REGEXP_LIKE (insert_data_rec.emp_no, '[#!$^&*%./\|]');
    -- Check that no special characters exist in the string
    SELECT COUNT (*)
      INTO emp_no_count_special_char
      FROM DUAL
    WHERE NOT REGEXP_LIKE (insert_data_rec.emp_no, '[#!$^&*%./\|]');
    {code}
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Checking for Paragraph sign / Return Character with indexOf()

    Hello all
    Al want to use String.indexIf() method to check for any Paragraph signs, or Return characters in a string, then delete or change them.
    I already tried the following, without success!
    int index = myAddress.indexOf('\r');
    and ('\n')
    Please help
    Thanks in advance
    Jaco

    just try to use a StringBuffer or the more diffcult way put the string into a StringTokenizer and set for delimitters all the paragraphs and whitespaces and then tokenize the string. You just have to determine the length of the splitstring and then you know where the characters are you look for

  • Check for zero

    I am looking for a way to check input fields for zero values in my action listener and bring up a message dialog if it finds one. I can get it to look for null or alpha characters but I can't figure out how to look for zero. Any suggestion would be appreciated. My action listener code is below...
    public class MyActionListener1 implements ActionListener
        double newAmount;
        double newRate;
        double newTerm;
        // Tell the JButton (calcButton) what to do when clicked.
        public void actionPerformed(ActionEvent evt)
            try
                AbstractButton calcButton = (AbstractButton)evt.getSource();
                newAmount = Double.parseDouble(principleValueText.getText());
                newRate = Double.parseDouble(rateAPRText.getText());
                newTerm = Double.parseDouble(termYearsText.getText());
                pmtText.setText(nf.format(getMortgagePmt(newAmount, newTerm, newRate)));
                pmtText.setForeground(Color.red);
                principleValueText.setText(nf.format(newAmount));
                rateAPRText.setText(np.format(newRate/100));
                termYearsText.setText(ni.format(newTerm));
            // Privide error handeling to check for valid input.
            catch(NumberFormatException nfe)
                JOptionPane.showMessageDialog(null, "The value must only contain digits",
                                                          "Input Error", JOptionPane.WARNING_MESSAGE);
    }

    I don't quite understand your problem, but I think what you're saying is that if any of the parsed numbers are 0, you want to show a dialog box that says you can't have "0" values?
    There are two ways to do this: after parsing each number, you can just simply use the block:
    if(number == 0){
        JOptionPane.showMessageDialog(null,"...","...",...);
    }You can call the JOptionPane methods whenever you want to in your program.
    Now, another way of doing this, though kind of like over kill, you can use a block like this:
    if(number == 0)
        throw new IllegalArgumentException("Number cannot be 0!");and then after your catch(NumberFormatException) block put:
    catch(IllegalArgumentException iae){
        JOptionPane.showMessageDialog(null,iae.getCause(),"Error",JOptionPane.ERROR_MESSAGE);
    }or something to that effect. once again, second solution is kind of overkill, but it would work (and stop the execution of the rest of the method)
    If I completely understood your problem, I'm sorry =D
    Alex

  • Need script to check for duplicate file names when copying a folder

    Hello,
    I am a new applescript user trying to write what I believe should be a simple script. I was planning on using the "add-new item alert" script as a template.
    Basically I have people copying folders of photos into a library folder, but I don't want the Finder to copy the photo if it already exists in the library. The images in the library are organized into subfolders.
    I need a script that will check all the file names in the new folder against all the file names in the library, and NOT add the new one if it already exists.
    If anyone can help it would be greatly appreciated,
    Thanks,
    C

    I have a script that "kind of" works. The only problem I've seen is that it gets confused when filenames contain characters that are fine in Macland but not good in Unixland. Forward slashes are a good example of this.
    In this case I have a folder in my home named "copytest" Inside copytest are two folders:
    Source (containing the images to be added)
    Dest (My existing library of images)
    It also assumes that the folder of images to be added contains no sub-folders. Hope this helps.
    tell application "Finder"
    set theSource to folder "source" of folder "copytest" of home
    set imagesToBeCopied to name of every file of theSource
    end tell
    repeat with theFile in imagesToBeCopied
    try
    if (do shell script "find -r ~/copytest/dest -name " & quoted form of (theFile as string)) is not equal to "" then
    --The file exists. Don't copy it
    else
    --the file doesn't already exist. Copy it.
    end if
    on error
    return "Failed while trying to check for existence of a file"
    end try
    end repeat

  • Check For Line Feed

    hi again, im trying to check for a line feed character in an xml file.
    im using the following code:
    NodeList nodeList = ElementNode.getChildNodes();
    for(int i = 0; i < nodeList.getLength(); i++) {
                        if(nodeList.item(i).getNodeValue().equals("\n")) {
                             System.out.println("Line Feed!");
                        }else
                             System.out.println(nodeList.item(i).getNodeName());
                   }For some reason it never prints out "Line Feed!"
    i used a transformer object to indent my xml like so,
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
                   transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");so im wondering why am i not picking up the line feeds?
    many thanks

    ive found out what the line feed character is, but when im trying to read back in my xml,
    i have it indented to 4 places (see above), this will no doubt add 4 white spaces to different parts of the xml, as well as new line characters.does it also add carriage returns?this is causing me problems reading back in.Is there any classes i can use to remove all the white spaces, new line characters etc.. so i can just get at the xml content (elements, CDATA, comments etc..)?
    many thanks!

  • Validate email -- check for more than one dot

    I'm looking to validate and email address and I found how to check for a single dot "[email protected]"  with  email_txt.text.indexOf('.') < 0  but I want to also want to check to see if the user may have entered two dots "[email protected]"
    I tried:
    email_txt.text.indexOf('.') < 0 ||  email_txt.text.indexOf('.') >2 but that makes it puke all of the time.
    I also tried:
    email_txt.text.indexOf('.') < 0 && >2 and that one threw all kinds of errors.
    I don't know if I've ever seen anyone check for that, so I might be a little over zealous, but I thought I'd give it a try.
    Thanks in advance

    function validateEmailF(inputEmail:String):Boolean {
        //check for spaces
        if (inputEmail.indexOf(" ")>0) {
            return false;
        //bust the email apart into what comes before the @ and what comes after
        var emailArray:Array = inputEmail.split("@");
        //make sure there's exactly one @ symbol
        //also make sure there's at least one character before and after the @
        if (emailArray.length != 2 || emailArray[0].length == 0 || emailArray[1].length == 0) {
            return false;
        //bust apart the stuff after the @ apart on any . characters
        var postArray:Array = emailArray[1].split(".");
        //make sure there's at least one . after the @
        if (postArray.length<2) {
            return false;
        //make sure there's at least 1 character in in each segment before, between and after each .
        for (var i:Number = 0; i<postArray.length; i++) {
            if (postArray[i].length<1) {
                return false;
        //get what is left after the last .
        var suffix = postArray[postArray.length-1];
        //make sure that the segment at the end is either 2 or 3 characters
        if (suffix.length<2 || suffix.length>3) {
            return false;
        //it passed all tests, it's a valid email
        return true;
    }

  • Check for null and empty - Arraylist

    Hello all,
    Can anyone tell me the best procedure to check for null and empty for an arraylist in a jsp using JSTL. I'm trying something like this;
    <c:if test="${!empty sampleList}">
    </c:if>
    Help is greatly appreciated.
    Thanks,
    Greeshma...

    A null check might not be you best option.  If your requirement is you must have both the date and time component supplied in order to populate EventDate, then I would use a Script Functoid that takes data and time as parameters.
    In the C# method, first check if either is an empty string, if so return an empty string.
    If not, TryParse the data, if successful, return a valid data string for EventDate.  If not, error or return empty string, whichever satsifies the requirement.

  • Acmcneill1ug 14, 2014 7:16 AM I have IMac OSX 10.9.4, 4GB,Processor 3.06 with Intell2Duo. I would like to check for Malware. I run a TechTool Pro 6 every month and that comes up great. When check how much memory I am using, with only Safar

    Acmcneill1ug 14, 2014 7:16 AM
    I have IMac OSX 10.9.4, 4GB,Processor 3.06 with Intell2Duo. I would like to check for Malware. I run a TechTool Pro 6 every month and that comes up great.
    When check how much memory I am using, with only Safari open I am using 3.9 and more of her 4.0 memory. She is very. very slow in processing. I had 4000
    trash to clean out and it took her over an hour to expel. Also for some reason Safari will not allow me to click on a link, in my G-mail, and let it go to the page.
    It has a sign saying a pop-up blocker is on and will not let me do it. I must open the stamp to look at my e-mails and if I have redirected link now I can do it.
    I have not changed my preferences so where is this pop-up blocker?
    I have looked at preferences on Safari and Google, which I do not understand Google, and do not see where this blocker could be.
    Malware is something I want to make sure is not on my computer. Tech Tool Pro 6 is all I know of and it does not detect Malware.
    Help.
    Ceil

    Try Thomas Reed's Adware removal tool. He posts extensively in the communities.
    Malware Guide - Adware
    Malware Discussion

  • Checking for PDF 1.7 compatibility in Preflight (Acrobat 9 Pro)

    Hi,
    I've noticed that in the given Preflight profiles in Acrobat 9 there is no compatibility check for PDF 1.7, only 1.6. is there a profile i can load? or a set of checks i can make a profile in order to determine 1.7 compatibility?
    Thanks,
    Yair Agmon.

    Hi,
    Knowing a PDF file's version premits deduction of what version "compatibility" is present.
    Version 1.7 (Acrobat 8.x) lacks compatibility for Acrobat 9.x specific features.
    Version 1.6 (Acrobat 7.x) lacks compatibility for Acrobat 8.x specific features.
    And so forth.
    Certainly, not an elegantly simple approach; but, nevertheless it is functional.
    Using Acrobat Professional/Extended 9.x -
    Open the Preflight dialog.
    Advanced > Preflight
    From the Options drop-down menu, Select "New Preflight Profile".
    The Prefight: Edit Profile dialog opens.
    A default profile name is provided (New Profile <number>).
    Initially, Click the Save button to save the profile. You can rename it later.
    Note that "New Profile" is placed in "Custom
    Now, locate your "New Profile" in the column at the left of the dialog and select
    "Custom checks".
    The available custom checks list loads in the pane to the right.
    Above and to the right is a "Find" field.
    Enter the string "version".
    A filtered list appears.
    A custom check is available for "versions newer than":
    1.2 | 1.3 | 1.4 | 1.5 | 1.6 | 1.7
    and there is a custom check for "version older than 1.3".
    Add the desired custom check to the profile. Save.
    Configure the check for Error | Warning | Info
    Info is "Notification" in the report that can be provided.
    Once you have configured "New Profile" it can be used by a Batch Sequence to check multiple files.
    When a Preflight is selected for use by a Batch Sequence you can configure for a "on success" and/or "on error" report.
    Be well...

Maybe you are looking for