How to Use String Patterns?

Hai all,
I need help, In my project i am using String patterns.
i need to search a string which contains special characters.
Ex:
1.Abstract{meaning}
I have to search Abstract in this case.
Another case is:
2.Moon
in this i Have to search Moon and
so on.
For this Source Code I had written is:
string input = args[0];
String pattern = "[0-9].*+\\{*\\}";
String pattern1 = "[0-9].*";
string line = "1.Abstract{meaning}";
string line1 = "1.Moon";
if( (Pattern.matches(pattern, line))||(Pattern.matches(pattern1, line1)) )
Pattern p = pattern.compile("\\.");
Pattern p1 = pattern.compile("\\{");
String[] tokens = p.split();
String[] tokens1 = p1.split();
for(int i = 0; i < tokens.length ; i++)
for(int j = 0; j < tokens1.length ; j++)
if((tokens.equals(input))||(tokens[j].equals(input)))
System.out.println(tokens[i]);
System.out.println(tokens[j]);
in this code it matching the 2nd case. it is not matchinf the 1st case.
please help me.
Thanks

look up for "Using formatters" in the FB help.
Essentially you'll instantiate a format, NumberFormatter for
numbers for example, and set it's properties like e.g. showing a
thousand separator and then one some event of the TextInput --
valueCommit for example -- you'll do something like:
ti.text = nf.format(ti.text)
this is would also give you opportunity to validate user
input using the same formatter and valid event.
ATTA

Similar Messages

  • How to use CQL patterns in CEP?

    Hi,
    How to use CQL patterns and what is the use ?

    Try the new Stream Explorer interface and check out the patterns section. These are pre-defined patterns that allow you to look for trends, missing events, duplicates, W Pattern, etc. These do in-memory incremental processing of data with high throughput and low latency.
    The SX user interface allows you to easily define a data stream and start applying a pattern. An Event Processing Network (EPN) with a CQL processor and the CQL are generated automatically and the results are immediately shown on the user-interface.

  • How to use lock pattern for ur home screen in pod touch 4g(ios 5)

    how to use lock pattern for ur home screen in pod touch 4g(ios 5)

    Video formats:
    H.264 video up to 720p, 30 frames per second, Main Profile level 3.1 with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats
    MPEG-4 video up to 2.5 Mbps, 640 by 480 pixels, 30 frames per second, Simple Profile with AAC-LC audio up to 160 Kbps per channel, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats
    Motion JPEG (M-JPEG) up to 35 Mbps, 1280 by 720 pixels, 30 frames per second, audio in ulaw, PCM stereo audio in .avi file format
    Support for 1024 by 768 pixels with Apple VGA Adapter; 576p and 480p with Apple Component AV Cable; 576i and 480i with Apple Composite AV Cable (cables sold separately)

  • How to use string variable onside quotes

    Hi,
    i would like to know how to use string variable onside quotes. what i mean is if i have a LOV variable P_STATUS as character string.
    and in my PL/SQL function i give a query as
    Q AS VARCHAR2(1000) := 'SELECT * FROM EMP
    WHERE STATUS = :P_STATUS';
    Is this correct. I Know that the above statement works when the LOV is an integer, but when i use a character LOV return value the above statement does not work. how can i get in the character LOV value.
    Can someone help me please.
    Thanks,
    Philip.

    916753 wrote:
    Yes I tried binding all the values separately. It is working, but, I am trying to pass all values by variableBut you can't. The variable is holding a single string value.... that is just 1 value. Your binding are expecting multiple values. You can't bind 1 string value and expect Oracle to magically know how to break your string up into seperate values for the bind variables. What if one of your bind variables actually needed e.g. a comma seperated string as it's value? How would Oracle know that?
    You must bind each thing seperately. That's the way cursors work.
    , because i have more than 150 tables in which data will be load. that's why i m trying to create a unique procedure to load data one by one table. Otherwise I have to write individual procedures for per procedures.It's a hard life being a software programmer, but somebody's got to do it. Unfortunately there are too many people who try and write "generic" procedures and expect them to just work. I mean why don't Oracle just implement some SQL command so you can do...
    execute immediate 'load all my tables';save us all the hassle eh!? ;)
    when i write all the columns like
    execute immediate (insert_string) using rc1.TOLL_ID, rc1.LANE_ID, rc1.RECEIVED_DATETIME, rc1.LANE_QUERY, c1.EXECUTED_DATETIME
    but it is not possible to generate runtime variable thats why I m trying to assign all values to a single variable and use it like
    execute immediate (insert_string) using (v_string)
    how can I separate the values and ho to use it .Don't use execute immediate. Use the DBMS_SQL package instead and bind your values dynamically with loops to cover all the columns you need etc.

  • How to use string format in TextInput?

    How to use string format in TextInput?
    Ex.
    HH:MM:SS when typing message appear in 12:34:56 form.
    N,NNN when typing message appear in 1,234,567 form.

    look up for "Using formatters" in the FB help.
    Essentially you'll instantiate a format, NumberFormatter for
    numbers for example, and set it's properties like e.g. showing a
    thousand separator and then one some event of the TextInput --
    valueCommit for example -- you'll do something like:
    ti.text = nf.format(ti.text)
    this is would also give you opportunity to validate user
    input using the same formatter and valid event.
    ATTA

  • How to use string to substitude into a parameter ,look @ msg 4 more detail

    How to use a screenname from an array of strings of screennames to set it to current screen
    Example:
    //screens
    Form logo;
    List cat,sub;
    int back;//previous screen index
    public String SCREEN[]={"logo","cat","sub"};
    if (command=cmdBack) display.setCurrent(SCREEN[back]);
    how???,i don't want to type in the screen name as i want it to be able to keep track of the screen displayed.
    Please Help
    thanks

    hi...just one suggeation...u may like it ...
    u can use a stack , as and when u view a screen push it onto the stack and with each press of "back" button u pop out . this way the back button functionality works perfectly no matter how u navigate between screens .
    sanjib

  • How to use String toString?

    hey guys,
    I've 2-D array and i would like to printout using String toString method. I'v used that method to printout non-array values but I really don't know how to display 2-D array using the String toString method. Can someone please help me? thanks in advance!

    I do not understand your question. Please post
    whatever code you have and indicate where you are
    stuck.I'm sure you're aware of the String toString method which is often used to display the output in different classes without the main method.
    I've following code:
    public static int bingoCard [][] = new int[SIZE][SIZE]; 
    public BingoCard()   {
            Integer ran = 0;
            for (i = 0; i < SIZE; i ++) {
                 if (i == 0) {
                    min = 1;
                    max = 15;
                } else {
                    min = max + 1;
                    max += 15;
    //             System.out.println("Min: " + min + " " + "Max: " + max);
                // generate all 15 balls in this range
                for (j = min; j <= max; j++) {
                    bC.add(new Integer(j));               
    //             // randomize the 15 balls           
                for (j = 0; j < SIZE; j++) {
                    while (bingoCard[i][j] == 0) {
                        ran = (Integer)bC.removeRandom(); // get Integer object back
                        if (max <= 15 && (ran.intValue() >= 1 && ran.intValue() <= 15))
                            bingoCard[i][j] = ran.intValue();              
                        else if(max <= 30 && (ran.intValue() >= 16 && ran.intValue() <= 30))
                            bingoCard[i][j] = ran.intValue();           
                        else if(max <= 45 && (ran.intValue() >= 31 && ran.intValue() <= 45))
                            bingoCard[i][j] = ran.intValue();              
                        else if(max <= 60 && (ran.intValue() >= 46 && ran.intValue() <= 60))
                            bingoCard[i][j] = ran.intValue();             
                        else if(max <= 75 && (ran.intValue() >= 61 && ran.intValue() <= 75))
                            bingoCard[i][j] = ran.intValue();
    //                 System.out.println("Numbers in the card: " +  bingoCard[i][j]);
            bingoCard[2][2] = 0;       
    Now, i want to dipslay the bingoCard[][] using following method
    public String toString () { // return that array } instead of using following method which displays it for now
    public static void display () {
            for ( i = 0; i < SIZE; i++) {
                 System.out.print(" "+ columnTitles[i] +"   ");
            System.out.println(); 
            for (i = 0; i < SIZE; i++) {  
                for (j = 0; j < SIZE; j++) {               
                    System.out.print(" "+bingoCard[j] +" ");
    if (bingoCard[j][i] < 10)
    System.out.print(" ");
    System.out.println();
    Any help would be really apperciated. =]

  • How to use string functions (substr or ltrim or replace)  in OLAP universe.

    cost element (0COSTELMNT) - 10 CHAR
    Controlling area (0CO_AREA) - 4 CHAR
    [0COSTELMNT].[LEVEL01].[[20COSTELMNT]].[Value]
    cOST ELEMENT is compounded/prefixed with Controlling Area. I just want to see cost element without conrolling area in the BO report.
    Currenlty BO unierse is build based on bex query. I am able to suppress the compounding object in bex query by chaning controlling area to 'No display'. But still BO Webi report displaying compounded values in the report. (Bex report works as expected)
    eg: Current display in reort.
    controlling area/cost element.
    AB00/2222
    AB00/2223
    AB00/2224
    Wanted like  below:
    2222
    2223
    2224
    I think by using string fucntions (substring, ltrim or  replace etc.), I can get the required result. But I am having issues with syntax. I have used like below.
    substr(0COSTELMNT ; 5 ; 10)
    substr(0COSTELMNT; 5 ; Length(0COSTELMNT)-5)
    substr(0COSTELMNT; Pos(0COSTELMNT;"/")+1;10)
    ltrim(0COSTELMNT,'AB00/')
    What is the syntax for substring/replace functions in OLAP universe. Technical name of cost element in OLAP  universe is [0COSTELMNT].[LEVEL01].[[20COSTELMNT]].[Value].
    I want to fix this at universe level not at report level as  i am using cost element in filter/variable section of the report. Please provide me syntax for above example.

    Hi,
    In fact SAP BW MDX supports limited string manipulation and only with NAME and UNIQUENAME attributes.
    Here are some samples that you can use in universes:
    MID([0COSTELMNT].currentmember.NAME,1,4)
    LEFT([0COSTELMNT].currentmember.NAME,2)
    RIGHT([0COSTELMNT].currentmember.NAME,3)
    MID([0COSTELMNT].currentmember.UNIQUENAME ,1,4)
    LEFT([0COSTELMNT].currentmember.UNIQUENAME ,2)
    RIGHT([0COSTELMNT].currentmember.UNIQUENAME ,3)
    Didier

  • How to use Class Pattern to find match word ?

    Hi All:
    Now I want find some words in a article . for example , I want to find a word ---"book" . For this purpose , I use java.util.regex.Pattern to do that . Following is my code
    String tmpStr = ".*?[\\W]+book[\\W]+.*?";                         
    Pattern p = Pattern.compile(tmpStr);
    Matcher m = p.matcher(testStr);                // assume testStr is the article
    while ( (m1.find()) ) {
             System.out.println("find");
    }                    However , this code only help me to find some like " book " , " book! " , " !book " . But I also want to find some like "book " or " book" , since there aren't space before book or no space after book . How can I correct my code to do that ?
    Thanks in advance

      String tmpStr = "\\bbook\\b";

  • How to use string as a column name

    Hello,
    I have a fn getField() that returns a column delimited string - amt1,amt2 . I want to use this string as the column name in a second query on table MASTER_AMT and get the values for amt1 and amt2...so when i try....
    select getField( 'NPC_NOYTG' ) FROM MASTER_AMT
    WHERE ACTI_CODE = 'NPOR';
    the o/p i get is...
    GETFIELD('NPC_NOYTG')
    AMT1,AMT2,AMT3
    instead of...
    AMT1 AMT2
    500 0
    that i require.
    Any ideas on how to convert the string returned to a column name?
    Thanks very much
    rgds

    Try this ....
    In SQL*PLUS
    SQL> var ref_c refcursor
    --- Then type the follwing at SQL prompt
    declare
    cursor cur is
    select column_name
    from user_tab_columns a,
         (select upper(getField( 'NPC_NOYTG')) fld FROM MASTER_AMT
         WHERE ACTI_CODE = 'NPOR') col_lst
    WHERE
    instr(chr(44) || col_lst.fld || chr(44),chr(44) || a.COLUMN_NAME || chr(44) ) > 0
    AND table_name = 'MASTER_AMT';
    v_str varchar2(1000):= ' ';
    begin
    for c in cur loop
    v_str := v_str || c.column_name || ',' ;
    end loop;
    v_str := substr(v_str,1,len(v_str)-1);
    open :ref_c for
    'select ' || v_str || ' from master_amt';
    end;      
    --- after executing the above block, type the following at SQL prompt
    SQL > print ref_c
    Please let me know if this works for you. This should for any number of columns returned by the function.
    Shakti
    (http://www.impact-sol.com)
    (Developers of Guggi Oracle)

  • How to use string control as terminal window

    Hello All
    I am trying to create a terminal window in my VI and to do this i have a string control and a string indicator.
    I want the user to be able to write a command in the terminal and when hitting enter the control should update, but not before! I would
    like the user to be able to enter multiple commands without having to re-click the control with the mouse, so it has to stay in the
    control window. 
    The output from this string control is input to a invoke node to an external motor controller, which replies with a string input to the string indicator.
    Tried to do some event case, but not quite sure how I am going to detect only the enter command.
    Any ideas how to preceed?
    Thanks
    Regards
    Tommy
    Solved!
    Go to Solution.

    Yeah, in your event structure, look for an event of your string control called "key down"...on the left, there are several parameters coming up (char, vkey etc.) where you can use for example the char to look for char=13 (return).
    look here: http://zone.ni.com/reference/en-XX/help/371361B-01/lvprop/control_key_down/
    good luck
    christian 
    THINK G!! ;-)
    Using LabView 2010 and 2011 on Mac and Win
    Programming in Microsoft Visual C++ (Win), XCode (Mac)

  • How to use String.replaceAll(String regex, String replacement)?

    hi,
    I'd like to use the String.replaceAll call to replace all occurrences of a pattern in a string with a string inputted from the user.
    The problem is that replaceAll seems process the replacement string first. For example, the code below won't work
    public class StringTest {
         public static void main(String [] arg) throws Exception {
              String input = "oooIoooIooo";
              input=input.replaceAll("I","\\");
              System.out.println(input);
    }So the only option seems to be to manually process the user input string into a form that can be accepted by String.replaceAll?
    The only thing I can find from looking through the API is that you'd need to convert each backslash to a double-backslash?
    is this the right thing to be doing?
    thanks,
    asjf

    just to clarify, at the moment I think the solution is to do this
    public class StringTest {
         public static void main(String [] arg) throws Exception {
              String input = "oooIoooIooo";
              String raw = "\\";
              input=input.replaceAll("I",raw.replaceAll("\\\\","\\\\\\\\"));
              System.out.println(input);
    }

  • How to use String to name objects

    Hello,
    I have an array of 100 Strings and I want to create 100 objects of a Class with same names as the ones in the Strings, is there any way to do it?
    I have searched the forum and I think it can be done with a Map Class, but I wonder if there is a more convenient way.
    Thanks,
    Kostas

    Any way other than actually putting them into the map? What did you have in mind? Some kind of zen map, perhaps? :-)
    This is exactly the sort of thing a map is for - mapping instances of one class to instances of another; in this case mapping strings to Resources. So this is almost certainly the best data structure.
    How you obtain the names and the Resources is another matter. Taking them in as separate arrays (which might have different lengths) may not be the best solution. A better solution might be to make the Resources able to identify themselves so you could add them to the Map and ask them for their names to use as the keys.
    Also, I notice that you're creating an array of these resources, but the array will be initialised with 100 (actually, 101 - 0..100) null pointers. This is probably not what you want. And even correctly initialising the array with Resources constructed through the default constructor might not be what you want. You could, maybe, wrap your map with another class which queries the map and lazily creates Resources for you if they don't already exist.

  • How to use string class?

    Hi, experts:
    Have you run HelloStrings sample in "Thinking in C++" book? The source code is following. But when I compile, it throws error:"string in not defined". How to write correct makefile? Thanks! /Denise
    //: C02:HelloStrings.cpp
    // The basics of the Standard C++ string class
    #include <string>
    #include <iostream>
    using namespace std;
    int main() {
    string s1, s2; // Empty strings
    string s3 = "Hello, World."; // Initialized
    string s4("I am"); // Also initialized
    s2 = "Today"; // Assigning to a string
    s1 = s3 + " " + s4; // Combining strings
    s1 += " 8 "; // Appending to a string
    cout << s1 + s2 + "!" << endl;
    } ///:~

    The most likely cause is that the "using namespace std;" line is missing from the file you are compiling, or commented out.
    Using C++ 5.6 and the exact file I listed earlier, I get this result:
    % CC -V hello.cc
    CC: Sun C++ 5.6 2004/06/02
    /set/mercury/dist/fcs.2/sparc-S2/opt/SUNWspro/prod/bin/c++filt: Sun C++ 5.6 2004/06/02
    ccfe: Sun C++ 5.6 2004/06/02
    ld: Software Generation Utilities - Solaris Link Editors: 5.9-1.377
    Copy/paste the hello.cc file I listed above and try compiling it.
    If you still get errors, your compiler was not installed correctly, or the installation has become corrupted.
    If you want to poke around a bit more before re-installing, try this:
    CC -H -c HelloStrings.cc |& grep string
    The -H option lists all the header files that were read. You should see this, assuming your compiler is installed in /opt:
    /opt/SUNWspro/prod/include/CC/Cstd/./string <------- string header
         /opt/SUNWspro/prod/include/CC/std/string.h
              /usr/include/string.h
                   /usr/include/iso/string_iso.h
         /opt/SUNWspro/prod/include/CC/Cstd/rw/string_ref
    If in particular you do not see /opt/SUNWspro/prod/include/CC/Cstd/./string, or if the "string" header marked above comes from some other location, something is definitely wrong with the compiler installation.
    If you see the correct string header, run "wc" on that header. You should see this:
    1858 6099 68105 string
    If not, the string header is corrupted.
    To re-install, refer to the Installation Guide that comes with Sun Studio 9. Follow the instructions for uninstalling Sun Studio 9. Then run the product installer, paying close attention to any warnings or error messages. I strongly recommend using the product installer, and not trying to install the product yourself directly from the packages.

  • How to use String Tokeniser inside this for loop?

    [i][i]hi there..
    i am reading all the file inside a directory and get the latest modified file than i have to tokenise it and juz read the number. For example my file name that is last modified will be abc_123.txt but i just want it to appear 123.
    i manage to do it separately how can i put the tokeniser inside my for loop?
    my directory
    for (int i = 0; i < files.length; i++)
                        if(files[i].isFile())
                             if(lastModifiedFile == null){
                             lastModifiedFile = files[i];
                             String mylastModifiedFile = lastModifiedFile.toString();
                             StringTokenizer tokens = new StringTokenizer (mylastModifiedFile,".");
                             String modified = tokens.nextToken().substring(modified.length-4);*/
                             if(lastModifiedFile != null)
                                  if(lastModifiedFile.lastModified() < files[i].lastModified())
                                       lastModifiedFile = files[i];
    my tokeniser is this
    String mylastModifiedFile = lastModifiedFile.toString();
                             StringTokenizer tokens = new StringTokenizer (mylastModifiedFile,".");
                             String modified = tokens.nextToken().substring(modified.length-4);*/
                   }

    [i][i][i]hi there..
    i am reading all the file inside a directory and get ...
    tokens.nextToken().substring(modified.length-4);*/
                   }[/i][i][/i][/i][/i]Is there some reason for this baroque formatting? Please use the
    code tags as explained in one of your other threads on this topic:
    http://forum.java.sun.com/thread.jspa?threadID=793441&messageID=4510858#4510858

Maybe you are looking for