Results 1 to 8 of 8
  1. #1
    Radu is offline Member
    Join Date
    Dec 2009
    Posts
    29
    Rep Power
    0

    Question Pattern.compile Help

    How can I enter multiple names in a TextField using Pattern.compile.
    I tried with
    Java Code:
    public static final Pattern PATTERN_NAME=Pattern.compile("[A-Z]('[A-Z])?([a-z])+");
    
    and
    
    public static final Pattern PATTERN_NAME=Pattern.compile("(\\b([A-Z])([a-z])+([ -])?)+");
    The name that I want to enter is something like this:
    John 'oryley george Lasló abu-MOHAMED

    random charachers as you can see from the example

  2. #2
    leen's Avatar
    leen is offline Member
    Join Date
    Mar 2011
    Posts
    16
    Rep Power
    0

    Post

    hi
    you can read that

    Pattern (Java 2 Platform SE v1.4.2)


    i hope benefit

    GOOD LUCK


    please help his
    Last edited by leen; 04-12-2011 at 11:13 AM.
    I did not understand anything in Java:(
    Therefore, future lost:eek:

  3. #3
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Im confused why you need to use pattern for this? Do you want to only allow certain characters to show up? Have the text field contain some initial value? Please let me know what you are trying to do.

  4. #4
    Radu is offline Member
    Join Date
    Dec 2009
    Posts
    29
    Rep Power
    0

    Default

    Quote Originally Posted by sunde887 View Post
    Im confused why you need to use pattern for this? Do you want to only allow certain characters to show up? Have the text field contain some initial value? Please let me know what you are trying to do.
    Yes. Like * or $ etc. I'm trying to create a text field for name (name and surname, ititials etc. a name with many components as you can see from the example but containing name like O'neal etc)
    Last edited by Radu; 04-13-2011 at 07:19 AM.

  5. #5
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    I don't really understand what you want still. Did you read the link provided by leen?

    You want to have the Text field contain a name when the GUI is created?

    Do you want the user to type in a name? What do you want to happen as they type.

  6. #6
    Radu is offline Member
    Join Date
    Dec 2009
    Posts
    29
    Rep Power
    0

    Default

    Yes! I want the user type names.

  7. #7
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Ok, why do you need a pattern? Why can't they just type there name in?

  8. #8
    Radu is offline Member
    Join Date
    Dec 2009
    Posts
    29
    Rep Power
    0

    Default

    Java Code:
    package proiect_final;
    
    import java.awt.Dimension;
    import java.awt.Toolkit;
    import java.util.regex.Pattern;
    
    public class Constante {
        
        public static final Dimension DIMENSIUNE_ECRAN=Toolkit.getDefaultToolkit().getScreenSize();
        public static final Dimension DIMENSIUNE_FEREASTRA=new Dimension(800,600);
        public static final String DIRECTOR_POZE="poze";
        public static final char[] COD_CORECT={'1','2','3'};
        public static final Pattern PATTERN_NUME=Pattern.compile("[A-Z]('[A-Z])?([a-z])+");
        public static final Pattern PATTERN_PRENUME=Pattern.compile("(\\b([A-Z])([a-z])+([ -])?)+");
        public static final Pattern PATTERN_CNP=Pattern.compile("[01]([0-9]){12}");
        public static final Pattern PATTERN_TELEFON_MOBIL=Pattern.compile("07([0-9]){8}");
        public static final Pattern PATTERN_TELEFON_FIX=Pattern.compile("0[2-3]([0-9]){8}");
    }
    Here is part of the program were I use pattern.

    P.S. If someone can help via E-mail send me PM

Similar Threads

  1. url-pattern
    By Leila in forum Java Servlet
    Replies: 0
    Last Post: 12-16-2010, 08:58 AM
  2. strategy pattern and bridge pattern
    By jomypgeorge in forum New To Java
    Replies: 2
    Last Post: 12-13-2010, 06:13 AM
  3. Class pattern to generate following pattern:-
    By vxs in forum New To Java
    Replies: 5
    Last Post: 07-15-2010, 12:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •