Toggle Theme Editor
Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Charcoal

Tiện Ích Cực Nhỏ Cho Việc Kiểm Tra & Học Regex ( Biểu Thức Chính Quy)

Discussion in 'CongDongJava member's Java Software' started by Dinh Nguyen, 14/8/19.

  1. Dinh Nguyen

    Dinh Nguyen New Member

  2. Dinh Nguyen

    Dinh Nguyen New Member

  3. Joe

    Joe Thành viên VIP

    Chao ban Dinh Nguyen,
    to post a source codes you start with [ php] ... the codes ... [/php]
    to post a web picture you start with [ IMG] ..link to image...[/IMG]
    to link a sentence you start with [ URL='...the link...']...sentence..[/URL]
    Note: the blank between square bracket [ and php or IMG or URL='....' is here to show you and must be omitted when you code it.

    Here is your posting:
    PHP:
    package com.dinhns.javaregexcheck;
     
    import java.awt.Color;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    import javax.swing.text.BadLocationException;
    import javax.swing.text.DefaultHighlighter;
    import javax.swing.text.Highlighter;
    import javax.swing.text.Highlighter.HighlightPainter;
     
    /**
     *
     * @author dinh.ns2111@gmail.com
     */
    public class FindMatchRegEx extends javax.swing.JFrame {
     
        
    /**
         * Creates new form FindMatchRegEx
         */
        
    public FindMatchRegEx() {
            
    initComponents();
            
    this.setResizable(false);
            
    this.setLocationRelativeTo(null);
            
    textAreaToFindMatches.requestFocus();
            
    buttonFindMatch.addActionListener((e) -> {
                
    int count=0;
                
    textAreaMatches.setText("");
                
    textAreaToFindMatches.getHighlighter().removeAllHighlights();
                
    String s textAreaToFindMatches.getText();
                
    String regex textFeildRegEx.getText();
                
    Pattern p Pattern.compile(regex);
                
    Matcher m p.matcher(s);
                
    boolean b;
                while (
    m.find()) {
                    
    HighlightPainter painter
                            
    = new DefaultHighlighter.DefaultHighlightPainter(Color.ORANGE);
                    
    int p0 m.start();
                    
    int p1 m.end();
                    try {
                        
    textAreaToFindMatches.getHighlighter().addHighlight(p0p1painter);
                    } catch (
    BadLocationException ex) {
                        
    Logger.getLogger(FindMatchRegEx.class.getName()).log(Level.SEVEREnullex);
                    }
                   
                    
    textAreaMatches.append("\nMatch ("+(++count)+"):  \"");
                    
    int len=textAreaMatches.getText().length();
                    
    System.out.println(len);
                    
    textAreaMatches.append(m.group());
                    
    textAreaMatches.append("\" at ("+m.start()+","+(m.end()-1)+")\n");
                    
    textAreaMatches.append("-----------------------------");
                    try {
                        
    textAreaMatches.getHighlighter().addHighlight(len, (len+m.group().length()), painter);
                    } catch (
    BadLocationException ex) {
                        
    Logger.getLogger(FindMatchRegEx.class.getName()).log(Level.SEVEREnullex);
                    }
     
                }
            });
        }
     
        
    /**
         * This method is called from within the constructor to initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is always
         * regenerated by the Form Editor.
         */
        
    @SuppressWarnings("unchecked")
        
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
        
    private void initComponents() {
     
            
    buttonFindMatch = new javax.swing.JButton();
            
    textFeildRegEx = new javax.swing.JTextField();
            
    labelStringTextArea = new javax.swing.JLabel();
            
    jLabel1 = new javax.swing.JLabel();
            
    jScrollPane1 = new javax.swing.JScrollPane();
            
    textAreaMatches = new javax.swing.JTextArea();
            
    jSeparator1 = new javax.swing.JSeparator();
            
    labelStringTextArea1 = new javax.swing.JLabel();
            
    jScrollPane2 = new javax.swing.JScrollPane();
            
    textAreaToFindMatches = new javax.swing.JTextArea();
     
            
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
     
            
    buttonFindMatch.setText("Find matches");
     
            
    labelStringTextArea.setText("String");
     
            
    jLabel1.setText("RegEx");
     
            
    textAreaMatches.setEditable(false);
            
    textAreaMatches.setColumns(20);
            
    textAreaMatches.setRows(5);
            
    jScrollPane1.setViewportView(textAreaMatches);
     
            
    jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
     
            
    labelStringTextArea1.setText("Matches");
     
            
    textAreaToFindMatches.setColumns(20);
            
    textAreaToFindMatches.setRows(5);
            
    jScrollPane2.setViewportView(textAreaToFindMatches);
     
            
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            
    getContentPane().setLayout(layout);
            
    layout.setHorizontalGroup(
                
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .
    addGroup(layout.createSequentialGroup()
                    .
    addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .
    addGroup(layout.createSequentialGroup()
                            .
    addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .
    addGroup(layout.createSequentialGroup()
                                    .
    addGap(341341341)
                                    .
    addComponent(labelStringTextAreajavax.swing.GroupLayout.PREFERRED_SIZE51javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATEDjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE))
                                .
    addGroup(layout.createSequentialGroup()
                                    .
    addGap(026Short.MAX_VALUE)
                                    .
    addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .
    addComponent(buttonFindMatchjavax.swing.GroupLayout.PREFERRED_SIZE596javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .
    addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILINGfalse)
                                            .
    addComponent(textFeildRegExjavax.swing.GroupLayout.Alignment.LEADING)
                                            .
    addComponent(jScrollPane2javax.swing.GroupLayout.Alignment.LEADINGjavax.swing.GroupLayout.DEFAULT_SIZE596Short.MAX_VALUE)))))
                            .
    addGap(181818))
                        .
    addGroup(javax.swing.GroupLayout.Alignment.TRAILINGlayout.createSequentialGroup()
                            .
    addGap(00Short.MAX_VALUE)
                            .
    addComponent(jLabel1javax.swing.GroupLayout.PREFERRED_SIZE53javax.swing.GroupLayout.PREFERRED_SIZE)
                            .
    addGap(288288288)))
                    .
    addComponent(jSeparator1javax.swing.GroupLayout.PREFERRED_SIZE11javax.swing.GroupLayout.PREFERRED_SIZE)
                    .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .
    addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .
    addComponent(jScrollPane1javax.swing.GroupLayout.PREFERRED_SIZE279javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addGroup(layout.createSequentialGroup()
                            .
    addGap(131131131)
                            .
    addComponent(labelStringTextArea1javax.swing.GroupLayout.PREFERRED_SIZE70javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .
    addGap(252525))
            );
            
    layout.setVerticalGroup(
                
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .
    addGroup(javax.swing.GroupLayout.Alignment.TRAILINGlayout.createSequentialGroup()
                    .
    addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .
    addGroup(layout.createSequentialGroup()
                            .
    addGap(00Short.MAX_VALUE)
                            .
    addComponent(labelStringTextArea1)
                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .
    addComponent(jScrollPane1javax.swing.GroupLayout.PREFERRED_SIZE523javax.swing.GroupLayout.PREFERRED_SIZE))
                        .
    addGroup(layout.createSequentialGroup()
                            .
    addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE)
                            .
    addComponent(labelStringTextArea)
                            .
    addGap(181818)
                            .
    addComponent(jScrollPane2javax.swing.GroupLayout.PREFERRED_SIZE378javax.swing.GroupLayout.PREFERRED_SIZE)
                            .
    addGap(181818)
                            .
    addComponent(jLabel1)
                            .
    addGap(777)
                            .
    addComponent(textFeildRegExjavax.swing.GroupLayout.PREFERRED_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.PREFERRED_SIZE)
                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .
    addComponent(buttonFindMatchjavax.swing.GroupLayout.PREFERRED_SIZE58javax.swing.GroupLayout.PREFERRED_SIZE))
                        .
    addComponent(jSeparator1))
                    .
    addContainerGap())
            );
     
            
    pack();
        }
    // </editor-fold>//GEN-END:initComponents
     
        /**
         * @param args the command line arguments
         */
        
    public static void main(String args[]) {
            
    /* Set the Nimbus look and feel */
            //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
            /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
             * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
             */
            
    try {
                for (
    javax.swing.UIManager.LookAndFeelInfo info javax.swing.UIManager.getInstalledLookAndFeels()) {
                    if (
    "Nimbus".equals(info.getName())) {
                        
    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                        break;
                    }
                }
            } catch (
    ClassNotFoundException ex) {
                
    java.util.logging.Logger.getLogger(FindMatchRegEx.class.getName()).log(java.util.logging.Level.SEVEREnullex);
            } catch (
    InstantiationException ex) {
                
    java.util.logging.Logger.getLogger(FindMatchRegEx.class.getName()).log(java.util.logging.Level.SEVEREnullex);
            } catch (
    IllegalAccessException ex) {
                
    java.util.logging.Logger.getLogger(FindMatchRegEx.class.getName()).log(java.util.logging.Level.SEVEREnullex);
            } catch (
    javax.swing.UnsupportedLookAndFeelException ex) {
                
    java.util.logging.Logger.getLogger(FindMatchRegEx.class.getName()).log(java.util.logging.Level.SEVEREnullex);
            }
            
    //</editor-fold>
     
            /* Create and display the form */
            
    java.awt.EventQueue.invokeLater(new Runnable() {
                public 
    void run() {
                    new 
    FindMatchRegEx().setVisible(true);
                }
            });
        }
     
        
    // Variables declaration - do not modify//GEN-BEGIN:variables
        
    private javax.swing.JButton buttonFindMatch;
        private 
    javax.swing.JLabel jLabel1;
        private 
    javax.swing.JScrollPane jScrollPane1;
        private 
    javax.swing.JScrollPane jScrollPane2;
        private 
    javax.swing.JSeparator jSeparator1;
        private 
    javax.swing.JLabel labelStringTextArea;
        private 
    javax.swing.JLabel labelStringTextArea1;
        private 
    javax.swing.JTextArea textAreaMatches;
        private 
    javax.swing.JTextArea textAreaToFindMatches;
        private 
    javax.swing.JTextField textFeildRegEx;
        
    // End of variables declaration//GEN-END:variables
    }
    and the image:
    [​IMG]
     
    Last edited: 15/8/19
    Dinh Nguyen likes this.
  4. Dinh Nguyen

    Dinh Nguyen New Member

    Ok , thank Joe !
     
  5. Dinh Nguyen

    Dinh Nguyen New Member

  6. Joe

    Joe Thành viên VIP

    the image must be a web-image, not a file from google-drive which is displayed for download. It's better to create an account at any free web-image host. For example: THIS imgbb.com. It's simple: make a screenshot, upload it to imgbb.com, retrieve the direct link then insert into the tag [ IMG]imgbb.com/my_screenshot.png[/IMG]
     
    Last edited: 16/8/19
    Dinh Nguyen likes this.
  7. Dinh Nguyen

    Dinh Nguyen New Member

    That’s great joe !
     
    Last edited by a moderator: 16/8/19
  8. Dinh Nguyen

    Dinh Nguyen New Member

    Update :
    [​IMG][​IMG]
     
    Joe likes this.
  9. Dinh Nguyen

    Dinh Nguyen New Member

    PHP:
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package com.dinhns.javaregexcheck;
     
    import java.awt.Color;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    import javax.swing.text.BadLocationException;
    import javax.swing.text.DefaultHighlighter;
    import javax.swing.text.Highlighter.HighlightPainter;
     
    /**
     *
     * @author dinh.ns2111@gmail.com
     */
    public class FindMatchRegEx extends javax.swing.JFrame {
     
        
    /**
         * Creates new form FindMatchRegEx
         */
        
    public FindMatchRegEx() {
            
    initComponents();
            
    this.setResizable(false);
            
    this.setLocationRelativeTo(null);
            
    textAreaToFindMatches.requestFocus();
            
    buttonFindMatch.addActionListener((e) -> {
                
    int count 0;
                
    int flag_CANON_EQ check_CANON_EQ.isSelected() ? Pattern.CANON_EQ 0;
                
    int flag_CASE_INSENSITIVE  check_CASE_INSENSITIVE.isSelected() ? Pattern.CASE_INSENSITIVE 0;
                
    int flag_COMMENTS  check_COMMENTS.isSelected() ? Pattern.COMMENTS 0;
                
    int flag_DOTALL  check_DOTALL.isSelected() ? Pattern.DOTALL 0;
                
    int flag_LITERAL  check_LITERAL.isSelected() ? Pattern.LITERAL 0;
                
    int flag_MULTILINE  check_MULTILINE.isSelected() ? Pattern.MULTILINE 0;
                
    int flag_UNICODE_CASE  check_UNICODE_CASE.isSelected() ? Pattern.UNICODE_CASE 0;
                
    int flag_UNICODE_CHARACTER_CLASS  check_UNICODE_CHARACTER_CLASS.isSelected() ? Pattern.UNICODE_CHARACTER_CLASS 0;
                
    int flag_UNIX_LINES  check_UNIX_LINES.isSelected() ? Pattern.UNIX_LINES 0;
                
    int flag=flag_CANON_EQ|flag_CASE_INSENSITIVE|flag_COMMENTS|flag_DOTALL|flag_LITERAL|
                        
    flag_MULTILINE|flag_UNICODE_CASE|flag_UNICODE_CHARACTER_CLASS|flag_UNIX_LINES;
                
    textAreaMatches.setText("");
                
    textAreaToFindMatches.getHighlighter().removeAllHighlights();
                
    String s textAreaToFindMatches.getText();
                
    String regex textFeildRegEx.getText();
     
                
    Pattern p Pattern.compile(regex,flag);
                
    Matcher m p.matcher(s);
                
    boolean b;
                while (
    m.find()) {
                    
    HighlightPainter painter
                            
    = new DefaultHighlighter.DefaultHighlightPainter(Color.ORANGE);
                    
    int p0 m.start();
                    
    int p1 m.end();
                    try {
                        
    textAreaToFindMatches.getHighlighter().addHighlight(p0p1painter);
                    } catch (
    BadLocationException ex) {
                        
    Logger.getLogger(FindMatchRegEx.class.getName()).log(Level.SEVEREnullex);
                    }
     
                    
    textAreaMatches.append("\nMatch (" + (++count) + "):  \"");
                    
    int len textAreaMatches.getText().length();
                    
    System.out.println(len);
                    
    textAreaMatches.append(m.group());
                    
    textAreaMatches.append("\" at (" m.start() + "," + (m.end() - 1) + ")\n");
                    
    textAreaMatches.append("-----------------------------");
                    try {
                        
    textAreaMatches.getHighlighter().addHighlight(len, (len m.group().length()), painter);
                    } catch (
    BadLocationException ex) {
                        
    Logger.getLogger(FindMatchRegEx.class.getName()).log(Level.SEVEREnullex);
                    }
     
                }
            });
        }
     
        
    /**
         * This method is called from within the constructor to initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is always
         * regenerated by the Form Editor.
         */
        
    @SuppressWarnings("unchecked")
        
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
        
    private void initComponents() {
     
            
    buttonFindMatch = new javax.swing.JButton();
            
    textFeildRegEx = new javax.swing.JTextField();
            
    labelStringTextArea = new javax.swing.JLabel();
            
    jLabel1 = new javax.swing.JLabel();
            
    jScrollPane1 = new javax.swing.JScrollPane();
            
    textAreaMatches = new javax.swing.JTextArea();
            
    jSeparator1 = new javax.swing.JSeparator();
            
    labelStringTextArea1 = new javax.swing.JLabel();
            
    jScrollPane2 = new javax.swing.JScrollPane();
            
    textAreaToFindMatches = new javax.swing.JTextArea();
            
    check_CANON_EQ = new javax.swing.JCheckBox();
            
    check_MULTILINE = new javax.swing.JCheckBox();
            
    check_DOTALL = new javax.swing.JCheckBox();
            
    check_COMMENTS = new javax.swing.JCheckBox();
            
    check_CASE_INSENSITIVE = new javax.swing.JCheckBox();
            
    check_LITERAL = new javax.swing.JCheckBox();
            
    check_UNICODE_CASE = new javax.swing.JCheckBox();
            
    check_UNICODE_CHARACTER_CLASS = new javax.swing.JCheckBox();
            
    check_UNIX_LINES = new javax.swing.JCheckBox();
     
            
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
     
            
    buttonFindMatch.setText("Find matches");
     
            
    labelStringTextArea.setText("String");
     
            
    jLabel1.setText("RegEx");
     
            
    textAreaMatches.setEditable(false);
            
    textAreaMatches.setColumns(20);
            
    textAreaMatches.setRows(5);
            
    jScrollPane1.setViewportView(textAreaMatches);
     
            
    jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
     
            
    labelStringTextArea1.setText("Matches");
     
            
    textAreaToFindMatches.setColumns(20);
            
    textAreaToFindMatches.setRows(5);
            
    jScrollPane2.setViewportView(textAreaToFindMatches);
     
            
    check_CANON_EQ.setText("CANON_EQ");
     
            
    check_MULTILINE.setText("MULTILINE");
     
            
    check_DOTALL.setText("DOTALL");
            
    check_DOTALL.addActionListener(new java.awt.event.ActionListener() {
                public 
    void actionPerformed(java.awt.event.ActionEvent evt) {
                    
    check_DOTALLActionPerformed(evt);
                }
            });
     
            
    check_COMMENTS.setText("COMMENTS");
     
            
    check_CASE_INSENSITIVE.setText("CASE_INSENSITIVE");
            
    check_CASE_INSENSITIVE.addActionListener(new java.awt.event.ActionListener() {
                public 
    void actionPerformed(java.awt.event.ActionEvent evt) {
                    
    check_CASE_INSENSITIVEActionPerformed(evt);
                }
            });
     
            
    check_LITERAL.setText("LITERAL");
     
            
    check_UNICODE_CASE.setText("UNICODE_CASE");
     
            
    check_UNICODE_CHARACTER_CLASS.setText("UNICODE_CHARACTER_CLASS");
     
            
    check_UNIX_LINES.setText("UNIX_LINES");
     
            
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            
    getContentPane().setLayout(layout);
            
    layout.setHorizontalGroup(
                
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .
    addGroup(layout.createSequentialGroup()
                    .
    addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .
    addGroup(layout.createSequentialGroup()
                            .
    addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .
    addGroup(layout.createSequentialGroup()
                                    .
    addGap(341341341)
                                    .
    addComponent(labelStringTextAreajavax.swing.GroupLayout.PREFERRED_SIZE51javax.swing.GroupLayout.PREFERRED_SIZE))
                                .
    addGroup(layout.createSequentialGroup()
                                    .
    addGap(00Short.MAX_VALUE)
                                    .
    addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILINGfalse)
                                        .
    addComponent(textFeildRegExjavax.swing.GroupLayout.Alignment.LEADING)
                                        .
    addComponent(jScrollPane2javax.swing.GroupLayout.Alignment.LEADING)
                                        .
    addGroup(javax.swing.GroupLayout.Alignment.LEADINGlayout.createSequentialGroup()
                                            .
    addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .
    addComponent(check_CANON_EQ)
                                                .
    addComponent(check_DOTALL)
                                                .
    addComponent(check_UNICODE_CASE))
                                            .
    addGap(737373)
                                            .
    addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .
    addComponent(check_CASE_INSENSITIVE)
                                                .
    addComponent(check_LITERAL)
                                                .
    addComponent(check_UNICODE_CHARACTER_CLASS))
                                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATEDjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE)
                                            .
    addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .
    addComponent(check_COMMENTS)
                                                .
    addComponent(check_MULTILINE)
                                                .
    addComponent(check_UNIX_LINES))
                                            .
    addGap(797979))
                                        .
    addComponent(buttonFindMatchjavax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE))))
                            .
    addGap(181818))
                        .
    addGroup(layout.createSequentialGroup()
                            .
    addGap(311311311)
                            .
    addComponent(jLabel1javax.swing.GroupLayout.PREFERRED_SIZE53javax.swing.GroupLayout.PREFERRED_SIZE)
                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATEDjavax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE)))
                    .
    addComponent(jSeparator1javax.swing.GroupLayout.PREFERRED_SIZE11javax.swing.GroupLayout.PREFERRED_SIZE)
                    .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .
    addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .
    addComponent(jScrollPane1javax.swing.GroupLayout.PREFERRED_SIZE279javax.swing.GroupLayout.PREFERRED_SIZE)
                        .
    addGroup(layout.createSequentialGroup()
                            .
    addGap(131131131)
                            .
    addComponent(labelStringTextArea1javax.swing.GroupLayout.PREFERRED_SIZE70javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .
    addGap(252525))
            );
            
    layout.setVerticalGroup(
                
    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .
    addGroup(javax.swing.GroupLayout.Alignment.TRAILINGlayout.createSequentialGroup()
                    .
    addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .
    addGroup(layout.createSequentialGroup()
                            .
    addGap(018Short.MAX_VALUE)
                            .
    addComponent(labelStringTextArea1)
                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .
    addComponent(jScrollPane1javax.swing.GroupLayout.PREFERRED_SIZE523javax.swing.GroupLayout.PREFERRED_SIZE))
                        .
    addGroup(layout.createSequentialGroup()
                            .
    addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZEShort.MAX_VALUE)
                            .
    addComponent(labelStringTextArea)
                            .
    addGap(181818)
                            .
    addComponent(jScrollPane2javax.swing.GroupLayout.PREFERRED_SIZE272javax.swing.GroupLayout.PREFERRED_SIZE)
                            .
    addGap(181818)
                            .
    addComponent(jLabel1)
                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .
    addComponent(textFeildRegExjavax.swing.GroupLayout.PREFERRED_SIZEjavax.swing.GroupLayout.DEFAULT_SIZEjavax.swing.GroupLayout.PREFERRED_SIZE)
                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .
    addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .
    addComponent(check_CANON_EQ)
                                .
    addComponent(check_CASE_INSENSITIVE)
                                .
    addComponent(check_COMMENTS))
                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .
    addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .
    addComponent(check_MULTILINE)
                                .
    addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .
    addComponent(check_DOTALL)
                                    .
    addComponent(check_LITERAL)))
                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .
    addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .
    addComponent(check_UNIX_LINES)
                                .
    addComponent(check_UNICODE_CHARACTER_CLASS)
                                .
    addComponent(check_UNICODE_CASE))
                            .
    addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .
    addComponent(buttonFindMatchjavax.swing.GroupLayout.PREFERRED_SIZE58javax.swing.GroupLayout.PREFERRED_SIZE))
                        .
    addComponent(jSeparator1))
                    .
    addContainerGap())
            );
     
            
    pack();
        }
    // </editor-fold>                        
     
        
    private void check_CASE_INSENSITIVEActionPerformed(java.awt.event.ActionEvent evt) {                                                       
            
    // TODO add your handling code here:
        
    }                                                      
     
        private 
    void check_DOTALLActionPerformed(java.awt.event.ActionEvent evt) {                                             
            
    // TODO add your handling code here:
        
    }                                            
     
        
    /**
         * @param args the command line arguments
         */
        
    public static void main(String args[]) {
            
    /* Set the Nimbus look and feel */
            //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
            /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
             * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
             */
            
    try {
                for (
    javax.swing.UIManager.LookAndFeelInfo info javax.swing.UIManager.getInstalledLookAndFeels()) {
                    if (
    "Nimbus".equals(info.getName())) {
                        
    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                        break;
                    }
                }
            } catch (
    ClassNotFoundException ex) {
                
    java.util.logging.Logger.getLogger(FindMatchRegEx.class.getName()).log(java.util.logging.Level.SEVEREnullex);
            } catch (
    InstantiationException ex) {
                
    java.util.logging.Logger.getLogger(FindMatchRegEx.class.getName()).log(java.util.logging.Level.SEVEREnullex);
            } catch (
    IllegalAccessException ex) {
                
    java.util.logging.Logger.getLogger(FindMatchRegEx.class.getName()).log(java.util.logging.Level.SEVEREnullex);
            } catch (
    javax.swing.UnsupportedLookAndFeelException ex) {
                
    java.util.logging.Logger.getLogger(FindMatchRegEx.class.getName()).log(java.util.logging.Level.SEVEREnullex);
            }
            
    //</editor-fold>
     
            /* Create and display the form */
            
    java.awt.EventQueue.invokeLater(new Runnable() {
                public 
    void run() {
                    new 
    FindMatchRegEx().setVisible(true);
                }
            });
        }
     
        
    // Variables declaration - do not modify                     
        
    private javax.swing.JButton buttonFindMatch;
        private 
    javax.swing.JCheckBox check_CANON_EQ;
        private 
    javax.swing.JCheckBox check_CASE_INSENSITIVE;
        private 
    javax.swing.JCheckBox check_COMMENTS;
        private 
    javax.swing.JCheckBox check_DOTALL;
        private 
    javax.swing.JCheckBox check_LITERAL;
        private 
    javax.swing.JCheckBox check_MULTILINE;
        private 
    javax.swing.JCheckBox check_UNICODE_CASE;
        private 
    javax.swing.JCheckBox check_UNICODE_CHARACTER_CLASS;
        private 
    javax.swing.JCheckBox check_UNIX_LINES;
        private 
    javax.swing.JLabel jLabel1;
        private 
    javax.swing.JScrollPane jScrollPane1;
        private 
    javax.swing.JScrollPane jScrollPane2;
        private 
    javax.swing.JSeparator jSeparator1;
        private 
    javax.swing.JLabel labelStringTextArea;
        private 
    javax.swing.JLabel labelStringTextArea1;
        private 
    javax.swing.JTextArea textAreaMatches;
        private 
    javax.swing.JTextArea textAreaToFindMatches;
        private 
    javax.swing.JTextField textFeildRegEx;
        
    // End of variables declaration                   
    }
     
  10. Dinh Nguyen

    Dinh Nguyen New Member

  11. Dinh Nguyen

    Dinh Nguyen New Member

    Add replacement :
    [​IMG]
     
  12. Dinh Nguyen

    Dinh Nguyen New Member

Chia sẻ trang này

Loading...