Help with Understanding Regular Expressions

Hello Folks,
I need some help in understanding the Regular Expressions.
-- This returns the Expected string from the Source String. ", Redwood Shores,"
SELECT
  REGEXP_SUBSTR('500 Oracle Parkway, Redwood Shores, CA,aa',
                ',[^,]+,', 1, 1) "REGEXPR_SUBSTR"
  FROM DUAL;
REGEXPR_SUBSTR
, Redwood Shores,
However, when the query is changed to find the Second Occurrence of the Pattern, it does not match any. IMV, it should return ", CA,"
SELECT
  REGEXP_SUBSTR('500 Oracle Parkway, Redwood Shores, CA,aa',
                ',[^,]+,', 1, *2*) "REGEXPR_SUBSTR"
  FROM DUAL;
REGEXPR_SUBSTR
NULLCan somebody help me in understanding Why Second Query not returning ", CA,"?
I did search this forum and found link to thread "https://forums.oracle.com/forums/thread.jspa?threadID=2400143" for basic tutorials.
Regards,
P.

PurveshK wrote:
Can somebody help me in understanding Why Second Query not returning ", CA,"?With your query...
SELECT
  REGEXP_SUBSTR('500 Oracle Parkway, Redwood Shores, CA,aa',
                ',[^,]+,', 1, *2*) "REGEXPR_SUBSTR"
  FROM DUAL;You are looking for patterns of "comma followed by 1 or more non-comma chrs followed by a comma."
So, let's manually pattern match that...
'500 Oracle Parkway, Redwood Shores, CA,aa'
                   ^               ^
                   |               |
                           |
                           |
                  Here to here is the
                  first occurence.So the second occurance will start searching for the same pattern AFTER the first occurence.
'500 Oracle Parkway, Redwood Shores, CA,aa'
                                    ^
                                    |
i.e. the search for the second occurence starts heretherefore the first "," from that point is...
'500 Oracle Parkway, Redwood Shores, CA,aa'
                                       ^
                                       |
                                      hereand there is nothing there matching the pattern you are looking for because it only has the
"comma follwed by 1 or more non-comma chrs"... but it doesn't have the "followed by a comma"
...so there is no second occurence,

Similar Messages

  • Little help with this regular expression ?

    Greetings all,
    My string is like "P: A104, P105, K106" and I tried to split it using following regular expression ,but seems even though it returns 'true' as matched, it does not split the string.
    Finally what I want is String is array like {"P:","A104","P105","K106"}
    What seems to be the problem with my regular expression?
           String PAT1="[a-zA-Z]:\\s([a-zA-Z]\\d{1,}([,]\\s)?)*";
         String inp="P: A104, P105, K106";
         Pattern p=Pattern.compile(PAT1);
         System.out.println(p.matcher(inp).matches());
         String strs[]=inp.split(PAT1);
         for(String s:strs){
              System.out.println("part  "+s);
         }

    pankajjaiswal10 wrote:
    You can also use split(":|,")No, that will remove the colon and leave the whitespace intact. My understanding is that the OP wants to keep the colon and remove the commas and whitespace. I would use this: String[] strs = inp.split(",?\\s+");

  • Help with java regular expressions

    Hi all ,
    i am going to match a patternstring against an input string and print the result here is my code:
         import java.util.regex.*;
         import java.util.*;
         public class Main {
              private static final String CASE_INSENSITIVE = null;
              public static void main(String[] args)
              CharSequence inputStr = "i have 5 years FMCG saLEs exp on java/j2ee and i worked on java and j2ee and 2 projects on telecom java j2ee domain with your  with saLEs maNAger experience of java j2ee and c# having very good  on c++ exposure in JAVA"
             String patternStr = "\"java j2ee\" and \"c#\"";
              StringTokenizer st = new StringTokenizer(patternStr,"\",OR");
             Matcher matcher=null;
              while(st.hasMoreTokens()){
                   String s=st.nextToken();
                   Pattern pattern = Pattern.compile(s,Pattern.CASE_INSENSITIVE);
               matcher = pattern.matcher(inputStr);
               while (matcher.find()) {
                  String result = matcher.group();
                 if(!result.equalsIgnoreCase(" "))
                             System.out.println("result:"+result);
         when i compile this code i am getting the expected result...ie
    result:java j2ee
    result:java j2ee
    result: and
    result: and
    result: and
    result: and
    result: and
    result: and
    result:c#
    but when i replace String patternStr = "\"java j2ee\" and \"c#\""; with
    String patternStr = "\"java j2ee\" and \"c++\""; i am just getting c in the result instead of c++ ie i am getting result :
    result:java j2ee
    result:java j2ee
    result: and
    result: and
    result: and
    result: and
    result: and
    result: and
    result:C
    result:c
    result:c
    result:c
    result:c
    result:c
    result:c
    In the last lines i should get result:c++ instead of result: c
    Any ideas please
    Thanks

    In the last lines i should get result:c++ instead of result: cThe regular expression parser considers the plus sign '+' a special
    character; it means: one or more times the previous regular expression.
    So 'c++' means one or more 'c's on or more times. Obviously you don't
    want that, you want a literal '+' plus sign. You can do that by prepending
    the '+' with a backslash '\'. Unfortunately, the javac compiler considers
    a backslash a special character and therefore you have to 'escape'
    the backslash also, by adding another backslash. The result looks
    like this:"c\\+\\+"kind regards,
    Jos

  • What's wrong with the regular expression?

    Hi all,
    For the life of me I can not figure out what is wrong with this regular expression
    .*\bA specific phrase\.\b.*
    This is just an example the actual phrase can be an specific phrase. My problem comes when the specific phrase ends in a period. I've escaped the period but it still gives me an error. The only time I don't get an error is when I take off the end boundry character which will not suffice as a solution. I need to be able to capture all the text before and after said phrase. If the phrase doesn't have a period it would look like this...
    .*\bA specific phrase\b.*
    which works fine. So what is it about the \.\b combination that is not matching?
    I've been banging my head on this for a while and I'm getting nowhere.
    The application highlights text that comes from a server. The user builds custom highlights that have some options. Highlight entire line, match partial word, and ignore case. The code that builds my pattern is here
    String strHighlight = _strHighlight;
            strHighlight = strHighlight.replaceAll("\\*", "\\\\*");
            strHighlight = strHighlight.replaceAll("\\.", "\\\\.");
            String strPattern = strHighlight;
            if(_bEntireParagraph)
                if(_bPartialWord)
                    strPattern = ".*" + strHighlight + ".*";
                else               
                    strPattern = ".*\\b" + strHighlight + "\\b.*";           
            else
                if(_bPartialWord)
                    strPattern = strHighlight;
                else               
                    strPattern = "\\b" + strHighlight + "\\b";  
            if(_bIgnoreCase)
                _patHighlight = Pattern.compile(strPattern, Pattern.CASE_INSENSITIVE);
            else
                _patHighlight = Pattern.compile(strPattern);So for example I matching the phrase: The dog ate the cat. And that phrase came over in the following text: Look there's a dog. The dog ate the cat. "Oh my!"
    And my user has the entire line and ignore case options selected then my regex woud look like this: .*\bThe dog ate the cat\b.*
    That should get highlighted, but for some reason it doesn't. Correct me if I'm wrong but doesn't the regex read as follows:
    any characters
    word boundry
    The dog ate the cat[period]
    word boundry
    any characters until newline.
    Any help will be much appreciated

    A word boundary (in the context of regexes) is a position that is either followed by a word character and not preceded by one (start of word) or preceded by a word character and not followed by one (end of word). A word character is defined as a letter, a digit, or an underscore. Since a period is not a word character, the only way the position following it could be a word boundary is if the next character is a letter, digit or underscore. But a sentence-ending period is always followed by whitespace, if anything, so it makes no sense to look for a word boundary there. I think, instead of \b, you should use negative lookarounds, like so:   strPattern = ".*(?<!\\w)" + strHighlight + "(?!\\w).*";

  • Problems with java regular expressions

    Hi everybody,
    Could someone please help me sort out an issue with Java regular expressions? I have been using regular expressions in Python for years and I cannot figure out how to do what I am trying to do in Java.
    For example, I have this code in java:
    import java.util.regex.*;
    String text = "abc";
              Pattern p = Pattern.compile("(a)b(c)");
              Matcher m = p.matcher(text);
    if (m.matches())
                   int count = m.groupCount();
                   System.out.println("Groups found " + String.valueOf(count) );
                   for (int i = 0; i < count; i++)
                        System.out.println("group " + String.valueOf(i) + " " + m.group(i));
    My expectation is that group 0 would capture "abc", group 1 - "a" and group 2 - "c". Yet, I I get this:
    Groups found 2
    group 0 abc
    group 1 a
    I have tried other patterns and input text but the issue remains the same: no matter what, I cannot capture any paranthesized expression found in the pattern except for the first one. I tried the same example with Jakarta Regexp 1.5 and that works without any problems, I get what I expect.
    I am using Java 1.5.0 on Mac OS X 10.4.
    Thank to all who can help.

    paulcw wrote:
    If the group count is X, then there are X plus one groups to go through: 0 for the whole match, then 1 through X for the individual groups.It does seem confusing that the designers chose to exclude the zero-group from group count, but the documentation is clear.
    Matcher.groupCount():
    Group zero denotes the entire pattern by convention. It is not included in this count.

  • Need help in unix regular expressions

    Hi All,
    I'm new to shell scripting. Please help me in achieving this
    I am trying to a find regular expression that need to pick a file with begin with the below format and mask variable is called in xml file.
    currently the script accepts:
    mask="CLIENT_ID+'_ADHSUITE_IN_'+date2str(now,'MMddyy','US/Eastern')+'.txt'"
    But it should accept in the below format
    2595_ADHSUITE_IN_ANNWEL_030309_2009-02-10_15-12-46-000_648.TXT715.outpgp_out
    where CLIENT_ID=2595. How to place wild card character '*' in the below to accept file in the above format. here is what i made changes.
    mask="CLIENT_ID+'_ADHSUITE_IN_'*+date2str(now,'MMddyy','US/Eastern')*+'.TXT'*+'.outpgp_out'"
    Please help.
    Thanks

    I believe your statement is being passed over twice:
    First Pass: (This is done by something like javascript)
    CLIENT_ID+'_ADHSUITE_IN_'+'.*'+date2str(now,'MMddyy','US/Eastern')+'.*'+'.TXT'+'.*'+'.outpgp_out'In this pass the variables and functions that are enclosed in literals are processed:
    (1) CLIENT_ID is replaced by 2595 or whatever is current value is:
    (2) date2str(now,'MMddyy','US/Eastern') gets replaced by 040609 (if the current time now is 4th april 2009).
    So at the end of this first pass we have a string:
    2595_ADHSUITE_IN_.\*040609.\*.TXT.*.outpgp_outThis string at the end of the first pass is a Posix basic regular expression. (ref: [http://en.wikipedia.org/wiki/Regular_expression] ) accessed at time of post).
    This is the string I put in the Regular Expression text box on [http://www.fileformat.info/tool/regex.htm]
    and it matches "2595_ADHSUITE_IN_ANNWEL_040609_2009-01-27_17-02-28-000_631.TXT715.outpgp_out" for me (though I prefer my egrep test).
    I hope this is somewhat clearer. Remember I have very little information about your system/application and I make big guesses.
    NB: (I should thank Frits earlier for pointing my sloppiness between wildcards (for eg unix shell filename expansion) and regular expressions).
    For the second pass this used to compared other strings to see

  • Urgent help regarding Java regular expressions.

    hello everyone,
    I am trying to parse a html file which contains
    dyn.Img("http://www.boston.com/news/nation/articles/2007/06/21/bill_clinton_takes_bigger_campaign_role&h=306&w=410&sz=13&hl=en&start=43","","QFo9lqKeMR7uzM:","http://cache.boston.com/resize/bonzai-fba/AP_Photo/2007/06/21/1182410228_1931/410w.jpg","125","93","\x3cb\x3eBill Clinton\x3c/b\x3e takes bigger campaign \x3cb\x3e...\x3c/b\x3e","","","410 x 306 - 13k","jpg","www.boston.com","","","http://tbn0.google.com/images","1")
    the given above function many times. I have to fetch the whole functions into an array. So i have to write a regular expression which recognises the whole above string.
    Can anyone please help me.
    Thank you,
    chaitanya

    well if this is all you want
    http://cache.boston.com/resize/bonzai-fba/AP_Photo/2007/06/21/1182410228_1931/410w.jpg
    You can always substring it like chuck said
    ***BUT all the images would have to be .jpg for this to work***
    back = we.indexOf(".jpg");
    int x = 0;
    while (back < web.lastIndexOf(".jpg"))
                    back = web.indexOf("http",back+1);
                    picture[x] = web.substring(front, back);
                    x++;
                    front = back;
                  }       Might not be the best code but it worked with a website i had to parse
    Message was edited by:
    mark07

  • Problem with my regular expression

    Hi
    I am trying to find function declarations within source code. I've been trying to use regular expressions, but if anyone else has an easier / better way to do this, as ross perot said, "I'm all ears"
    Here's my regular expression printed out:
    sb = [.]*void foo[.]*
    sb is a stringbuffer variable, so the regex is [.]*void foo[.]*
    Can anyone tell me why when I run this pattern on my loaded source file it tells me that the pattern does not match? LOL can you help me fix this?

    I doubt that regex is a very good way to find method
    declarations, although you can probably make it work
    reasonably well for the most common cases.You've got a point. This is just to get the ball rolling. I don't want to have to do full syntax parsing yet.
    >
    In your particular situation, I'd guess it has to do
    with [.]*. I think that inside [], the
    dot is a literal dot, not "any character." If you
    want "zero or more of anything followed by void" then
    it's .*void.
    Just tried
    sb = .*void foo.*
    it still didn't work.
    In any case, however, this only covers methods
    returning void. For the more general case, I don'tI didn't give you all my code. I actually use a classloader and reflection to determine what the methods are, return values etc. So yes, void in this case is not overly flexible, but I can plug in whatever it is I'm looking for.
    think a simple regex will do it. You need a kind of
    tool that I can't recall the name of--something to
    build and examine an abstract syntax tree perhaps.
    Try starting here:
    http://www.google.com/search?q=java+abstract+syn
    tax+treeI'm not even sure it abstract syntax tree is what you
    want, but I think it's at least closer than regex.
    There might be something that's a step or two earlier
    in the compilation process that will give you what
    you want.

  • Problem with email regular expression

    I found the following regular expression from this website : http://www.regular-expressions.info/email.html
    \b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\bor
    ^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$I am using the following website to check its success, as well as my java app. : http://www.regexplanet.com/simple/index.html
    of course java has a problem with the illegal escape character so i add another "/".
    In both of my testing scenarios the regex value seems to fail. Am I missing something here?
    If anyone could also test this regex and verify or correct my problem I would be very grateful.
    Edited by: rico16135 on Jun 5, 2010 4:01 PM
    Edited by: rico16135 on Jun 5, 2010 4:02 PM

    rico16135 wrote:
    of course java has a problem with the illegal escape character so i add another "/".I seem to be missing the distinction between a forward slash / which is not an escape character, and a backslash \ which is.
    Also, if you show your actual Java code (in code tags, of course), and describe clearly and precisely what's going wrong--pasting in the exact, complete error message and indicating clearly which line caused it, if there is one--people will be in a better position to help you.

  • Find text Between tags with a Regular Expression

    I am trying to find specif text -- table names - within a
    <cfquery> tag in all my cfm files. I am using an extend find
    function in Homesite (I think Dreamweaver has the same
    functionality). This expression works:
    <[Cc][fF][qQ][uU][eE][rR][Yy]
    [^>]*>[^>]*(EventName|AttendeeName)[^>]*</[Cc][fF][qQ][uU][eE][rR][Yy]>
    for find the text EventName or AttendeeName. However, if
    there are other cf tags like <cfif> within the
    <cfquery>, then the tag/text is not found.
    Can anyone help? It is a useful expression to have if you are
    trying to transfer applications developed on a windows machine to
    a, say, linux machine, and have table name sensititvity issues with
    mySql.

    quote:
    Originally posted by:
    Newsgroup User
    Thanks for all the help. Comments below.
    > Thanks, but it:
    > 1) Captures everything between the first and last query
    in a script if there
    > is more than one cfquery in the script
    Oops: sorry. Stick a question mark after the asterisks to
    stop the matches
    being greedy.
    Used this:
    <[Cc][fF][qQ][uU][eE][rR][Yy].*?(EventName|AttendeeName)[^>].*?</[Cc][fF][qQ][uU][eE][rR][ Yy]>
    and got some finds again with multiple queries and some
    errors as mentioned below.
    > 2) It produces some regular expression errors in
    Homesite.
    Can't help you there. Sounds like HS's regex processor is
    bung: there's
    nothing non-standard or tricky about that regex (which might
    cause
    compatibility issues; JS vs PERL vs Java, etc).
    HS on the whole is bung (IMO). Have you considered using a
    text editor
    that is... err... *current*? ;-)
    No, can you suggest one. Just use HS for years and it does
    most of what I want.
    What sort of errors is it giving?
    Regular expression error No 17. Bad expression format or
    internal error.
    > The reason for this is I am developing on a windows
    machine with mysql and
    > want to use the application online on a linux machine
    where table names are
    > case sensitive. My code was not always faithful to that
    since in windows you
    > can be sloppy!
    Have you seen this:
    http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html
    It might be a better approach anyhow.
    Adam

  • Help needed regarding regular expressions

    hello
    i need to write a program that recieves a matematical expression and evaluates
    it...in other words a calculator :)
    i know i need to use regular expressions inorder to determine if the input is legal or not ,but i'm really having trouble setting the pattern
    the expression can be in the form : Axxze2223+log(5)+(2*3)*(5+4)
    where Axxze2223 is a variable(i.e a combination of letters and numbers.)
    where as: l o g (5) or log() or Axxx33aaaa or () are illegal
    i tried to set the pattern but i got exceptions or it just didnt work the way i wanted it .
    here's what i tried to do at least for the varibale form:
    "\\s*(*([a-zA-Z]+\\d)+)*\\s*";
    i'm really new to this...and i can't seem to set the pattern by using regular expressions,how can i combine all the rules to one string?
    any help or references would be appreciated
    thanks

    so i'll explain
    let's say i got token "abc22c"(let's call it "token")
    i wan't to check if it's legal
    i define:
    String varPattern = "\\s*[a-zA-Z]+\\d+\\s*";If you want to check a sequence of ASCII characters, longer than one, followed by a single digit, the whole possibly surrounded by spaces -- yes.
    >
    now i want to check if it's o.k
    so i check:
    token.matches(varPattern);
    am i correct?Quite. It's better to compile the Pattern (Pattern.compile(String)), create a java.util.regex.Matcher (Pattern#matcher(CharSequence)), and test the Matcher for Matcher#matches().
    (Class.method -> static method, Class#method -> instance method)
    >
    now i'm having problem defining pattern for log()
    sin() cos()
    that brackets are mandatory ,and there must be an
    expression inside
    how do i do that?First, I'd check the overall function syntax (a valid name, brackets), then whether what's inside the brackets is a valid expression (maybe empty), then whether that expression is valid for that function (presumably always?).
    I might add I'm no expert on parsing, so that's more a supposition than a guide.

  • Help with understanding key event propagation

    Hello,
    I am hoping someone can help me understand a few things which are not clear to me with respect to handling of key events by Swing components. My understanding is summarized as:
    (1) Components have 3 input maps which map keys to actions
    one for when they are the focused component
    one for when they are an ancestor of the focused component
    one for when they are in the same window as the focused component
    (2) Components have a single action map which contains actions to be fired by key events
    (3) Key events go to the currently focused component
    (4) Key events are consumed by the first matching action that is found
    (5) Key events are sent up the containment hierarchy up to the window (in which case components with a matching mapping in the WHEN_IN_FOCUSED_WINDOW map are searched for)
    (6) The first matching action handles the event which does not propagate further
    I have a test class (source below) and I obtained the following console output:
    Printing keyboard map for Cancel button
    Level 0
    Key: pressed C
    Key: released SPACE
    Key: pressed SPACE
    Level 1
    Key: pressed SPACE
    Key: released SPACE
    Printing keyboard map for Save button
    Level 0
    Key: pressed SPACE
    Key: released SPACE
    Level 1
    Key: pressed SPACE
    Key: released SPACE
    Printing keyboard map for Main panel
    Event: cancel // typed SPACE with Cancel button having focus
    Event: save // typed SPACE with Save button having focus
    Event: panel // typed 'C' with panel having focus
    Event: panel // typed 'C' with Cancel button having focus
    Event: panel // typed 'C' with Save button having focus
    I do not understand the following aspects of its behaviour (tested on MacOSX although I believe the behaviour is not platform dependent):
    (1) I assume that the actions are mapped to SPACE since the spacebar clicks the focused component but I don't explicitly set it?
    (2) assuming (1) is as I described why are there two mappings, one for key pressed and one for key released yet the 'C' key action only has a key pressed set?
    (3) assuming (1) and (2) are true then why don't I get the action fired twice when I typed the spacebar, once when I pressed SPACE and again when I released SPACE?
    (4) I read that adding a dummy action with the value "none" (i.e. the action is the string 'none') should hide the underlying mappings for the given key, 'C' the my example so why when I focus the Cancel button and press the 'C' key do I get a console message from the underlying panel action (the last but one line in the output)?
    Any help appreciated. The source is:
    import javax.swing.*;
    public class FocusTest extends JFrame {
         public FocusTest ()     {
              initComponents();
              setTitle ("FocusTest");
              setLocationRelativeTo (null);
              setSize(325, 160);
              setVisible (true);
         public static void main (String[] args) {
              new FocusTest();
    private void initComponents()
         JPanel panTop = new JPanel();
              panTop.setBackground (java.awt.Color.RED);
    JLabel lblBanner = new javax.swing.JLabel ("PROPERTY TABLE");
    lblBanner.setFont(new java.awt.Font ("Lucida Grande", 1, 14));
    lblBanner.setHorizontalAlignment (javax.swing.SwingConstants.CENTER);
              panTop.add (lblBanner);
              JPanel panMain = new JPanel ();
              JLabel lblKey = new JLabel ("Key:");
              lblKey.setFocusable (true);
              JLabel lblValue = new JLabel ("Value:");
    JTextField tfKey = new JTextField(20);
    JTextField tfValue = new JTextField(20);
    JButton btnCancel = new JButton (createAction("cancel"));     // Add a cancel action.
    JButton btnSave = new JButton (createAction("save"));          // Add a sve action.
              panMain.add (lblKey);
              panMain.add (tfKey);
              panMain.add (lblValue);
              panMain.add (tfValue);
              panMain.add (btnCancel);
              panMain.add (btnSave);
              add (panTop, java.awt.BorderLayout.NORTH);
              add (panMain, java.awt.BorderLayout.CENTER);
    setDefaultCloseOperation (javax.swing.WindowConstants.EXIT_ON_CLOSE);
    // Add an action to the panel for the C key.
              panMain.getInputMap (JComponent.WHEN_IN_FOCUSED_WINDOW).put (KeyStroke.getKeyStroke (java.awt.event.KeyEvent.VK_C, 0), "panel");
              panMain.getActionMap ().put ("panel", createAction("panel"));
              // FAILS ???
              // Add an empty action to the Cancel button to block the underlying panel C key action.
    btnCancel.getInputMap().put (KeyStroke.getKeyStroke (java.awt.event.KeyEvent.VK_C, 0), "none");
    // Print out the input map contents for the Cancel and Save buttons.
    System.out.println ("\nPrinting keyboard map for Cancel button");
    printInputMaps (btnCancel);
    System.out.println ("\nPrinting keyboard map for Save button");
    printInputMaps (btnSave);
              // FAILS NullPointer because the map contents are null ???
    System.out.println ("\nPrinting keyboard map for Main panel");
    // printInputMaps (panMain);
    private AbstractAction createAction (final String actionName) {
         return new AbstractAction (actionName) {
              public void actionPerformed (java.awt.event.ActionEvent evt) {
                   System.out.println ("Event: " + actionName);
    private void printInputMaps (JComponent comp) {
         InputMap map = comp.getInputMap();
         printInputMap (map, 0);
    private void printInputMap (InputMap map, int level) {
         System.out.println ("Level " + level);
         InputMap parent = map.getParent();
         Object[] keys = map.allKeys();
         for (Object key : keys) {
              if (key.equals (parent)) {
                   continue;
              System.out.println ("Key: " + key);
         if (parent != null) {
              level++;
              printInputMap (parent, level);
    Thanks,
    Tim Mowlem

    Use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the posted code retains its original formatting.
    1) In the Metal LAF the space bar activates the button. In the Windows LAF the Enter key is used to activate the button. Therefore these bindings are added by the LAF.
    2) The pressed binding paints the button in its pressed state. The released binding paint the button in its normal state. Thats why the LAF adds two bindings.
    In your case you only added a single binding.
    3) The ActionEvent is only fired when the key is released. Same as a mouse click. You can hold the mouse down as long as you want and the ActionEvent isn't generated until you release the mouse. In fact, if you move the mouse off of the button before releasing the button, the ActionEvent isn't even fired at all. The mouse pressed/released my be generated by the same component.
    4) Read (or reread) the [url http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html#howto]How to Remove Key Bindings section. "none" is only used to override the default action of a component, it does not prevent the key stroke from being passed on to its parent.

  • Help with understanding initial admin account vs. directory admin

    Hello,
    I am hoping someone can help me understand the initial admin account created when I was first configuring my server, and the directory admin.
    I have setup an advanced server, and when I was going through the initial setup I created an account that for this discussion I'll call "admin." Once the initial setup was finished I started using Workgroup manager to create accounts. I was informed that I should create a different directory admin so I did and for this discussion we'll call that account "diradmin."
    I am curious why the initial account of admin does not show up in workgroup manager, and why it does not show up as an option in Server Admin to assign permissions.
    Is this making any sense?
    Any explanation is greatly appreciated.
    Thank you,
    Scott

    Hi
    Presumably you used the Server Setup Assistant to configure Services prior to bringing the Server online?
    Not a good idea really. When choosing Advanced after the Server Software has been installed don't enable/configure any service apart from Remote Desktop. Once the Server setup is complete run all available updates. Once you've done that begin to configure required Services using Server Admin. Once you've done that begin to populate your directory nodes with users using WorkGroup Manager.
    The key to understanding the two accounts (a) System Administrator (admin UID 501) and (b) Directory Administrator (diradmin UID 100) is understanding which directory node you want to provide services to. The 'Local' node and the server in general (putting aside the super user 'root') will always be admin. Once you promote the Server from Standalone to OD Master you effectively create another Directory in addition to the Local one. This LDAP Directory can be used for all sorts of things. Principally enabling directory and contact information (amongst other things) to be shared/accessed with users that exist in that node with an enhanced authentication system (Kerberos) not available in the Local node and if the Server is in a Standalone Role. This LDAP Directory is controlled by diradmin. You won't be able to use admin for the LDAP node but you can use diradmin for the server in general - although I would not advise it. You can use root for both nodes - again I would not advise it unless absolutely necessary. Basically use admin to log into the Server and do the day to day stuff and use diradmin for the LDAP. Get into the habit of never having both applications open unless you are going to use them. Once you are done, quit out of them and leave them alone.
    To toggle between the two Directory nodes launch Workgroup Manager and click on the small blue globe below the main set of icons at the top and above the Users/Groups/Machines tabs. You should see at least 4 selections: Local, /LDAPv3/127.0.0.1, Search Policy and Other. If you don't see /LDAPv3/127.0.0.1 select Other and browse for it. If you still don't see it then you effectively don't have an OD Master. This will severely limit the ability of server to provide auot-mounting networked home folders as well as access to iCal Server's features amongst other things.
    Finally if you truly want LDAP and everything that goes with it then your DNS Service - wherever its placed - has to be correctly conigured and tested. This link is for a post that explains how to achieve this simply using the interface:
    http://discussions.apple.com/thread.jspa?threadID=1251475&tstart=45
    Depending on your network environment it might not be appropriate for you? However stick with it as it is a long post and you may find it useful?
    Tony

  • Help with understanding multi-threaded code

    Hi Everyone,
    I am currently reading a book on multi-threading and up until recently I have been able to understand what is going on. The thing is the complexity of the code has just jumped up about two gears without warning. The code is now using inner classes which I am trying to develop an understanding of but I am not finding it easy going, and the book has been lite on explanations. If anybody can help with the following code it will be really appreciated.
    public class SetPriority extends Object
         private static Runnable makeRunnable()
              Runnable r = new Runnable()
                   public void run()
                        for(int i=0; i<5; i++)
                             Thread t = Thread.currentThread();
                             System.out.println("in run() - priority=" + t.getPriority() +
                                          ", name=" + t.getName());
                             try{
                                  Thread.sleep(2000);
                             }catch(InterruptedException x){
                                  //ignore
              return r;
         public static void main(String[] args)
              Thread threadA = new Thread(makeRunnable(), "threadA");
              threadA.setPriority(8);
              threadA.start();
              Thread threadB = new Thread(makeRunnable(), "threadB");
              threadB.setPriority(2);
              threadB.start();
              Runnable r = new Runnable()
                   public void run()
                        Thread threadC = new Thread(makeRunnable(), "threadC");
                        threadC.start();
              Thread threadD = new Thread(r, "threadD");
              threadD.setPriority(7);
              threadD.start();
              try{
                   Thread.sleep(3000);
              }catch(InterruptedException x){
                   //ignore
              threadA.setPriority(3);
              System.out.println("in main() - threadA.getPriority()=" + threadA.getPriority());
    }My greatest challenge is understanding how the makeRunnable() method works. I don't understand how this inner class can be declared static and then multiple "instances" created from it. I know that I have no idea what is going on, please help!!!
    Thanks for your time.
    Regards
    Davo
    P.S.: If you know of any really good references on inner classes, particularly URL resources, please let me know. Thanks again.

    Yikes!! The good news is that you're unlikely to see such convoluted code in real life. But here we go.
    "private static Runnable makeRunnable()" declares a method that returns objects of type Runnable. The fact that the method is declared "static" is pretty irrelevant - I'll describe what that means later.
    The body of the method creates and returns an object of type Runnable. Not much special about it, except that you can give such an object to the constructor of class Thread and as a result the run() method of this Runnable object will be called on a new thread of execution (think - in parallel).
    Now the way it creates this Runnable object is by using the "anonymous inner class" syntax. In effect the method is doing the same as
    public class MyNewClass implements Runnable {
        public void run() {
            // All the same code inside run()
    public class SetPriority {
        private static Runnable makeRunnable() {
            Runnable r = new MyNewClass();
            return r;
        // The rest of the original code
    }Except you don't bother declaring MyNewClass. You're not interested in defining any new method signatures. You just want to create an object that implements Runnable and has certain instructions that you want inside the run() method. Think of the whole approach as shorthand.
    Think about this for a while. In the mean time I'll write up the "static".

  • Problem with java regular expression

    Hi,
    I try to use the regular expression as follows
    Pattern pattern = Pattern.compile("\wpub\w");
    Matcher matcher = null;
    matcher = pattern.matcher("38712pubeeqpwoiu");
    if (matcher.matches())
    System.out.println("Matched");
    else
    System.out.println("Not Matched");
    and I always get the answer as "Not Matched". I am not sure what is wrong with the code.
    thanks

    Use find() rather than matches().

Maybe you are looking for

  • Calling a function in sql prompt

    hi i have created one function in pl/sql lik following create or replace function ff(a number) return number is x number; begin select ann_pct_rate into x from naap30_appproducts where applicant_id = a; return x; end; while i called this in sql promp

  • Stored procedure could not be found.

    I'm upgrading my forms 6i to 11g on Windows. There is a procedure called center_window('WIN_MAIN',TRUE); in the pre-form trigger. There is no compiling error, but when the web page opens, it says "PRE-FORM trigger raised unhandled exception ORA-06508

  • Burned CD's won't play

    I am able to burn CD's and play them on my computer but not in my car? I don't understand. I have burned CD's before and they have worked but now they seem to not work in other players. Any thoughts out there?

  • SOAP Request Error in OSB Console

    Hi, I'm just learning OSB, and I tried to test out a web service project that I'd built. I deployed the project onto Weblogic, created the WSDL file for the business service in OSB and mounted that as well, but when I try to test it, the SOAP respons

  • Does iTunes 11 spell death for the album cover?

    Letter To Apple, From A Music Nerd.  iTunes 11 offers many visual interface innovations, however there is one drastic omission: the ability to display Album Artwork at a large size... (previously one could scale the art in "Cover Flow", or view the a