--- Note to learn regular expressions

2010-11-02  来源:本站原创  分类:Java  人气:106 

package zhengzebiaodashi;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class test
    //\b  Per character represents the beginning or end of a word
    //.  Represent any character
    //*  Per character, the character in front of a continuous re-use any number of times
    //   private static String demo = "\bhi\b.*\bLucy\b";

    //0  Beginning
    //\d  Digital
    //-  Is not a metacharacter, matches only itself  --  Hyphen
    // private static String tel = "0\d{2}-\d{8}";

    //\w  Matching letters or numbers or an underscore, or Chinese characters
    //\s  Matches any whitespace, including spaces  ,  Tabs  (Tab),  Line breaks, Chinese and other full-width space
    // \d+  Match 1 or more consecutive numbers
    //^,$  A position that matches  

    // private static String qq = "^\d{5,8}$";

    //  Escape characters     \.=.   \* = *

    //[aeiou]  To match any of the English vowel  ,[.?!]  Punctuation matching  (.  Or? Or  !).

    //|  Separate the different rules, it will test each condition from left to right  ,  If you meet a certain branches would not have to re-tube the other conditions of the  .

    //()  Group  ;
   // public static String demo = "[01]?\\d?\\d";

    //  Negate
     * \W   Not match any letters, numbers,  ,  Underscore the character of Chinese characters
        \S   Matches any whitespace character is not
        \D   Matches any non-numeric characters
        \B   Not the beginning or end of the match the location of the word
        [^x]   Matches any character other than the addition x
        [^aeiou]   In addition to these letters aeiou match any character other than  


  //  public static String demo = "[^abcd][^a]";

    //(?=exp)  It asserted itself behind the position appears to match the expression  exp
    //(?<=exp) Also called zero-width assertion is made after review, it asserts itself to appear in front of the expression to match  exp
     * @param args
    public static void main(String[] args)
//        String test = "eb";
//        Pattern pa = Pattern.compile(demo);
//        Matcher ma = pa.matcher(test);
//        if (ma.matches())
//        {
//            System.out.println("match ok");
//        }
//        else
//        {
//            System.out.println("math no");
//        }
        Pattern p = null;
        Matcher m = null;
        if (m.matches())
              System.out.println("match ok");
             System.out.println("math no");

  • --- Note to learn regular expressions 2010-11-02

    package zhengzebiaodashi; import java.util.regex.Matcher; import java.util.regex.Pattern; public class test { //\b Per character represents the beginning or end of a word //. Represent any character //* Per character, the character in front of a cont

  • 30 minutes to learn regular expressions 2010-03-09

    30 minutes to let you know what the regular expression, and it has some basic understanding, so you can own program or web page, use it. Ruhe use this tutorial is the most important - please give me 30 minutes if you do not use regular expressions ex

  • Half an hour to teach you learn regular expressions 2010-06-06

    http://www.xiaorui.net/post/29.html Must have a lot of people have headaches on a regular expression. Today, on my understanding, with some articles online in the hope that ordinary people can understand the expression. Come and share learning experi

  • Android to learn regular expressions 2010-10-12

    Learning Java regular expression: Because the regular expression is a very vast and complex system, this case started to name some of the concepts, more books and see their own exploration. \ \ Backslash \ T interval ('\ u0009') \ N newline ('\ u000A

  • The best I've seen web site to learn regular expressions 2010-06-01

    I had not previously studied the regular expression, whim few days ago, spent a day learning it at Zhaodao the contents of the Chinese general Bijiao obscure, then search for regular expression, google On Wei Zhi on the first row in the http:// www.r

  • Organize regular expressions, C # regular expression finishing notes 2010-10-31

    There was a time to learn regular expressions is very hot trend, then one day you can see in the CSDN regular expression in several posts, that time with forums and published by Wrox Press "C # strings and regular expressions reference manual" l

  • Using regular expressions 2011-01-06

    Author: Mitchell Harper Translation: iwind Original: http://www.devarticles.com/c/a/P ... LAR-Expressions-101 A regular expression is a specific format mode, can be used to find a string within another string usage. Several programming languages, inc

  • eclipse Using regular expressions to replace 2010-03-29

    At work, often encountered refactoring code, and some things obviously is very simple, but want to change things too much, too much duplication of effort, so learn some techniques are often used first gray Person.java in these static constant, note t

  • Regular expressions - the basics explained 2010-03-29

    [Original article, please retain or specify reproduced Source: http://www.regexlab.com/zh/regref.htm] Introduction regular expression (regular expression) is to use a "string" to describe a feature, and then to verify that the other "string

  • Grasp of regular expressions PHP, Part 2: How to deal with text in PHP 2010-04-15

    Original Address http://www.ibm.com/developerworks/cn/opensource/os-php-regex2/index.html March 9, 2008 This is the " master of regular expressions PHP "series, Part 2, by this article you will learn how to use some advanced regular expressions

  • find and grep command briefing and regular expressions 2010-06-07

    find and grep command briefing and regular expressions Two more useful commands and regular expressions In Shell we begin to learn a new programming knowledge, we first look at two more useful of the two commands, two command though not part of Shell

  • Using php to read and write xml dom (using the DOM library. SAX parser and regular expressions) 2010-07-15

    There are many techniques can be used with PHP to read and write XML. This article provides three methods of reading XML: using the DOM library, using the SAX parser and use regular expressions. Also introduced the use of DOM and PHP text template pr

  • Regular Expressions - Basics 2010-07-16

    Original: http://www.regexlab.com/zh/regref.htm Reveal the mystery of the regular expression Close highlight [Original article, reproduced, keep or indicate the source: http://www.regexlab.com/zh/regref.htm] Introduction Regular expression (regular e

  • Sorting out information on regular expressions 2010-11-28

    At the outset, the information is collected online, belongs to original author, I just concentrate on looking up the convenience of our beginner save time, be more focused to concentrate on learning is the on-line information on many parts of my coll

  • Regular Expressions Primer 2010-12-15

    Introduction regular expression (regular expression) describes a string matching pattern, can be used to: (1) Check whether a string contains a substring that matches a rule, and you can get this sub-string; (2) According to flexible matching rules o

  • as3 the use of regular expressions 2011-01-12

    Talk about regular expressions, AS3.0 in the introduction of regular expressions. Regular expressions are used to verify whether the text value of the particular model. There are four parts of regular expressions. 1 Motoko character. 2 yuan sequence.

  • Detailed JS regular expressions 2009-02-27

    Opening, or have to talk about ^ and $ that they are separately used to match the beginning and end of the string, the following examples to illustrate separately "^ The": there must be at the beginning of "The" string; "of despai

  • Regular Expressions 2010-03-29

    First, an overview of 1, regular expressions can be said to have provided any kind of programming language mechanisms, it mainly provides string processing capabilities. 2, regular expressions in the page address in the usage scenarios: 1) Forms Auth

  • java regular expressions 2010-03-29

    We all know, in the program development, will inevitably encounter the need match, find, replace, to determine the string to happen, but sometimes these situations more complex, if the pure coding solution, often a waste of programmer time and effort

  • Regular Expressions 3 2010-03-31

    1, "." As a wildcard, indicating any one character, for example: "ac" will match "anc", "abc", "acc"; 2 ,"[]", in [] is specified requirements can be matched characters, such as: "a [nbc] c&