Find a character in a string

How will you locate a specific character inside a string?
Thanks in advance!!!

> The best place to start with this type of question is
the documentation. Take a look at string functions:
>
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions-pt0_18.html
Absolutely.
Even if one types in "coldfusion find in string" in Google,
the first
result is on the money (for CFMX7, not CF8, but still).
Adam

Similar Messages

  • Find one character in a string and count the amount of times its found

    Hey SQL Forum experts.
    I have a string that is about 3000 characters long.
    I'm trying to search my string for the value '{'.
    Then I want to count how many times this value is found.
    How do I form the Oracle SQL to do this?

    Hi Colin,
    Try the following:
    SQL> var s varchar2(100)
    SQL>
    SQL> exec :s := 'Colin {{ Mackenzie {{{'
    PL/SQL procedure successfully completed.
    SQL> select length(:s) - length(replace(:s, '{')) Matches from dual;
       MATCHES
             5
    SQL> exec :s := 'I have a string that is about 3000 characters long'
    PL/SQL procedure successfully completed.
    SQL> select length(:s) - length(replace(:s, '{')) Matches from dual;
       MATCHES
             0Regards.

  • Finding a character in a string

    I have a RomanNumber class and an now trying to write a Calculator class. Im not sure how to go through the users input string to decide which operator they are using.
    VI + I
    VI - I
    I was using indexOf() but when I use that I can only pass in one operator to see if it is there ---- rNum.indexOf("+", 0)
    I can't do another indexOf() for the minus sign because it will throw an out of bounds exception because the plus sign won't necessarily be in the next expression.
    Any ideas?

    thanks.. figured it. I just used some if statements..
                   System.out.print("> ");
                   String rNum = stdin.nextLine();
                   int operatorPlus = rNum.indexOf("+", 0);
                   if(operatorPlus > 0){
                        String addFirst = rNum.substring(0, operatorPlus - 1);
                        String addSecond = rNum.substring(operatorPlus + 1, rNum.length());
                        RomanNumber rNumAdd1 = new RomanNumber(addFirst);
                        RomanNumber rNumAdd2 = new RomanNumber(addSecond);
                        RomanNumber add = rNumAdd1.plus(rNumAdd2);
                        System.out.println(add);
                   int operatorMinus = rNum.indexOf("-", 0);
                   if(operatorMinus > 0){
                        String minusFirst = rNum.substring(0, operatorMinus - 1);
                        String minusSecond = rNum.substring(operatorMinus + 1, rNum.length());
                        RomanNumber rNumMinus1 = new RomanNumber(minusFirst);
                        RomanNumber rNumMinus2 = new RomanNumber(minusSecond);
                        RomanNumber minus = rNumMinus1.minus(rNumMinus2);
                        System.out.println(minus);
                   }not sure if i should be using the substring method though. The user is allowed to enter the input in a couple different ways.
    VI + I
    VI+I
    either with or without whitespace. if they don't enter any whitespace then my substrings are messed up.

  • Function in oracle to find number of occurances of a character in a string

    hi,
    is there any function in oracle to find the number of ocurrances of a character in a string ?
    or is there any simple way of doing the same, rather than writting many lines of code as my program is already very complex.
    Maria

    Hi Maria,
    I don't know of such a function in Oracle, but maybe you could use this:
    length(search_string) - length(replace(search_string, character_to_be_found))
    For example: select length('Hello') - length ( replace('Hello', 'l')) from dual;
    Hope this is what you're looking for
    Danny

  • How to find out how many space character in setence (string var) ?

    Dear all Master,
    I need Your help please.
    Topic:
    Script Editor.
    My System:
    -CUCM 7.0
    -UCCX 7.0 premium
    -Nuance recognizer 9.0
    Question:
    ABC = string var.
    ABC = "this is sample"
    2 space character in ABC string var.
    How to find out how many space character in ABC var ?
    Regards,
    Susanto

    Hi
    Create a int variable called whatever you want, then insert a SET step.
    Set the variable to the new int you created, and then paste this into the 'value' field:
    String[] myarray = teststring.split(" ");
    return myarray.length -1 ;
    Basically it splits the string into chunks each time it hits the " " character.
    This results in an array of the resulting chunks (i.e. words), which is one more than the number of spaces. -1 from that, and you have your int variable set to the number of spaces.
    Regards
    Aaron
    Please rate helpful posts...

  • Alternative to find unique records with 60 character in selection string.

    Hi,
    We have to find out the values from the Infoobject. When we try to display data from an master object, the maximum length of selection it accepts 45 characters only but we need to input data around 60 characters in selection.
    Thing we tried:
    1. Selecting complete data without any condition but it did not work due to large volume of data.
    2. We tried to extract data from RSA3 but it did not work due to large volume of data.
    Please suggest me alternative to find unique records with 60 character in selection string.
    Regards,
    Himanshu Panchal.

    This sounds a bit strange. Are you perhaps mistakenly storing text data incorrectly as the primary key of the master data? I can't think of any actual data that is that length to ensure usinqueness - even GUIDs are maximum 32 characters - but GUIDs don't count as actual "readable" data although you do need to be able to select it from time to time. Perhaps you have a super secure password hash or something like it ?
    Also are you expecting to have a unique single record returned by your selection? To do this would in general REQUIRE that ALL the data is read because master data is not stored in the DB sorted by the data itself, but stored instead sorted by the it's SID.
    When you say you are selecting data from master data, which master data tables are you using? I have been able to select data from very large MD table (15 million unique records) using SE16 with no problems. Just enter the table name, and before you execute just count the number of records - it helps to know what you want to end up with.
    Have you tried using wild cards (the *) to preselect a smaller number of records : * a bit of your 60 character string *
    If you are trying to select from a non-key field you will encounter performance issues, but you can still use the wildcards, and get a result.
    Don't use RSA3 it was designed to make selections and group them into datapackets. It's not the same as selecting directly on the table in SE11 or SE16

  • How we can find the last character in a string(Urgent Plz!)

    Gurus!
    How we can find the last character in a string.
    e.g i have a string say "Str" with value "10-01".
    Now i want to find the last character in "Str" i.e "ONE=1".
    i am using Oracle developer 6i with Oracle 8i(1.7).
    Plz help!
    Many thanks!

    Use the substr() and length() functions -
    x := '10-01';
    y := substr(x, length(x));

  • Finding the occurences of | character in a string

    Hi There,
    I want to restrict the occurrences of | character in a string to some number. How can I make this check using regular expressions.
    Thanks,
    --JJ                                                                                                                                                                                                                                                                                                                               

    sabre150 wrote:
    guitar_man_F wrote:
    sabre150 wrote:
    jose wrote:
    So can you please suggest me a sample regex which will do this.
    --JJErr.. err.. err.. reply #2?Not quite. I believe he said restrict it to a certain max number of |, not remove all instances. I think.
    Look again. I remove anything that is NOT a '|' char and then count what is left.Oops! My bad! You're right. That would work.
    - Adam

  • How can I find special characters in a string

    Hi,
    I have a small task where I have to find special characters in a given string, Can anyone suggest.......................

    What is your definition of a "special character", could you be a bit more specific?
    Do you simply want to find the position of a specific character in the string?
    Can it occur more than once and you want to find all occurences?
    What should happen if the special character does not exist?
    For programming purposes, all 256 possible 8 bit characters (x00-xFF) can be treated the same. Non-printing characters can be entered in \-codes or hex display if needed.
    LabVIEW Champion . Do more with less code and in less time .

  • How to replace a character in a string with blank space.

    Hi,
    How to replace a character in a string with blank space.
    Note:
    I have to change string  CL_DS_1===========CM01 to CL_DS_1               CM01.
    i.e) I have to replace '=' with ' '.
    I have already tried with <b>REPLACE ALL OCCURRENCES OF '=' IN temp_fill_string WITH ' '</b>
    Its not working.

    Hi,
    Try with this..
    call method textedit- >replace_all
      exporting
        case_sensitive_mode = case_sensitive_mode
        replace_string = replace_string
        search_string = search_string
        whole_word_mode = whole_word_mode
      changing
        counter = counter
      exceptions
        error_cntl_call_method = 1
        invalid_parameter = 2.
    <b>Parameters</b>      <b> Description</b>    <b> Possible values</b>
    case_sensitive_mode    Upper-/lowercase       false Do not observe (default value)
                                                                       true  Observe
    replace_string                Text to replace the 
                                         occurrences of
                                         SEARCH_STRING
    search_string                 Text to be replaced
    whole_word_mode          Only replace whole words   false Find whole words and                                                                               
    parts of words (default                                                                               
    value)
                                                                               true  Only find whole words
    counter                         Return value specifying how
                                        many times the search string
                                        was replaced
    Regards,
      Jayaram...

  • [regex help]Find EXACT characters in a String.

    Ok, i got this so far ...
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    public class Testing2 {
        public static void main(String[] args) {
            Pattern p = Pattern.compile("[wati]");
            String text = "water";
            Matcher m = p.matcher(text);
            if (m.find()) {
                System.out.print("Found !");
    }With that code i got a match, but i ONLY want to find a match if the String matches the EXACTS characters in the Pattern ...
    in this case i got, 'w' 'a' 't' 'i', 'w' 'a' 't', are in water, but 'i' NOT, so i don't want to have a match !
    i don't know how to acomplish this :(
    hope you can help me, thanks in advance :D

    Username7260 wrote:
    Ok, i got this so far ...
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    public class Testing2 {
    public static void main(String[] args) {
    Pattern p = Pattern.compile("[wati]");
    String text = "water";
    Matcher m = p.matcher(text);
    if (m.find()) {
    System.out.print("Found !");
    }With that code i got a match, but i ONLY want to find a match if the String matches the EXACTS characters in the Pattern ...
    in this case i got, 'w' 'a' 't' 'i', 'w' 'a' 't', are in water, but 'i' NOT, so i don't want to have a match !
    i don't know how to acomplish this :(AFAIK there's no syntax in regular expressions to accomplish this. Try turning your string into a character array, sorting it, and then do a simple comparison.

  • Position of Character in a string

    Hi all,
    Consider the string ,
    "                                          Hello World"
    where the space before the letter H in Hello are empty character spaces. Can anyone tell me  how I can find the position of the letter H from the beginning of the sentence using String processing ?
    Thank you.

    Hi,
    Use SY-FDPOS system variable to find out the position of string.
    SY-FDPOS
    Location of hit in string operations.
      When you use CO,CN, CA, NA, CS, NS, CP, and NP, offset values are assigned to SYFDPOS
    depending on the search result.
      SEARCH … FOR … sets SY-FDPOS to the offset of the search string.
    Example:
    DATA: STRING(30) VALUE 'This is a fast first example.',
    POS TYPE I,
    OFF TYPE I.
    WRITE / STRING.
    SEARCH STRING FOR 'ft' ABBREVIATED.
    WRITE: / 'SY-FDPOS:', SY-FDPOS.
    POS = SY-FDPOS + 2.
    SEARCH STRING FOR 'ft' ABBREVIATED STARTING AT POS AND MARK.
    WRITE / STRING.
    WRITE: / 'SY-FDPOS:', SY-FDPOS.
    OFF = POS + SY-FDPOS -1.
    WRITE: / 'Off:', OFF.
    Regards,
    Bhaskar

  • The first character in a string

    I need to return the first character of a string, convert it to an integer, and compare it with another integer to see if they're the same. Sounds simple, even for me, but it won't work!!!
    // First question >
    Object userValue1 = JOptionPane.showInputDialog("Blah Blah Blah", JOptionPane.PLAIN_MESSAGE, null, options1, options1[0]);
    Variables.placeholder = (int) userValue1.charAt(0);This is the error I get
    C:\Documents and Settings\imholt\My Documents\OOPAttempt\21_Questions\Engine.java:170: cannot resolve symbol
    symbol : method charAt (int)
    location: class java.lang.Object
              Variables.placeholder = (int) userValue1.charAt(0);
    ^
    1 error
    I have a sneaky suspicion that once I find out what the problem was, I will ask myself why I didn't see it before...

    Try this
    Object userValue1 = JOptionPane.showInputDialog("Blah Blah Blah", JOptionPane.PLAIN_MESSAGE, null, options1, options1[0]);
    String str = userValue1.toString();
    Variables.placeholder = (int) str.charAt(0);

  • Replacing the \ character in a string

    I'm having trouble replacing a backslash in a string. I use .indexOf() to find the character, but I have to use an escape character and write .index("\\"), but it doesn't work - it returns -1.
    Also, replace() doesn't work - gives me an java.util.regex.PatternSyntaxException. Any ideas?
    thx

    The escape is for the compiler, I think, and then you need to escape the backslash.
    Try "\\\\".
    � {�                                                                                                                                                                                                           

  • Occurence of character in a string

    How can i find how many occurrence of a character in a string?
    Let's say: 010101010101010: there is 8 0 in that string.

    Here's just a different take on the same old problem, tested on 10g ... ;-)
    WITH t AS (SELECT '010101010101010' col1
                 FROM dual
    SELECT SYS_CONNECT_BY_PATH(symbol || ':' || TO_CHAR(no_of_sym), ' ') sym_stat
      FROM (SELECT SUBSTR(t.col1, LEVEL, 1) symbol
                 , COUNT(*)                 no_of_sym
                 , ROW_NUMBER() OVER (ORDER BY SUBSTR(t.col1, LEVEL, 1)) rn
              FROM t
           CONNECT BY LEVEL <= LENGTH(t.col1)
             GROUP BY SUBSTR(t.col1, LEVEL, 1)
    WHERE connect_by_isleaf = 1
    START WITH rn = 1
    CONNECT BY PRIOR rn = rn - 1
    => "0:8 1:7"C.

Maybe you are looking for

  • Assign not working

    Hi, The below assign statement is not working. I am checking whether billToMasterAccount is equal to the OfflineAccountNbr, then i am assigning the value to the target variable BillToAccount. Actually i am not supposed to use switch to check this con

  • In MIRO i am getting error message " vendor is not invoicing party in STO

    Dear All, i create one STO MM. This is plant to plant transfer STO. i entered few conditions. for this conditions i mentioned Vendor in condition detail. at the time of MIRO i am getting error message vendor is not invoicing party in PO ( STO). i che

  • Cancel Vendor Consigment Goods Issue document

    We are in the process of implementing Vendor Consignment and are unsure about one piece of the process.  This is the scenario: a) end user draws 2 parts out of Consigned stock b) MRKO will create a liability to the vendor c) end user only needed one

  • How do I fix an exporting error?

    I was working on a project, editing the final credits, when Premier Pro froze.  I was able to restart but then every time I opened a project the titler windowed opened at the start also.  I finally had to reinstall the entire program.  The titler pro

  • HELP PLEASE Acrobat Pro 8 for MAC PDF files printing all black pages (other file formats JPG and TIFF and XLS etc are fine)

    Pages print blackout  or black washout fuzzy when using scanned image to PDF creation or "Save As" PDF from JPG or other.  All other documents print perfectly.  Just not PDF's.  Worked fine up until today.  If I open JPG, print to PDF and try to prin