It does not start with XX. It is a case-insensitive regular expression.

Source: Internet
Author: User

1-line matching
2. It does not start with XX, for example, it does not start with www.
3 Case insensitive
4. Two units or operations, such as www & brvbar; 3 w.

Q:

1: multi-row matching

By default, the line terminator cannot be matched. (there are 6 line terminators. For details, see the Pattern api doc)
Similarly, you can use the compile parameter Pattern. DOTALL as the case does not match.

If it is case sensitive, add the Pattern. CASE_INSENSITIVE mentioned above. For example:

Import java. util. regex. Matcher;
Import java. util. regex. Pattern; public class Test {
  
Public static void main (String [] args ){
String str =
"<Table> n" +
"<Tr> n" +
"<Td> n" +
"Hello World! N "+
"</Td> n" +
"</Tr> n" +
"</Table> ";
String regex = "<td> (. + ?) </Td> ";
Pattern pattern = Pattern. compile (regex );
Matcher matcher = pattern. matcher (str );
While (matcher. find ()){
System. out. println (matcher. group (1). trim ());
        }          
    }  
}  

Code 2

Import java. util. regex. Matcher;
Import java. util. regex. Pattern; public class Test {
 
Public static void main (String [] args ){
String str =
"<Table> n" +
"<Tr> n" +
"<Td> n" +
"Hello World! N "+
"</Td> n" +
"</Tr> n" +
"</Table> ";
String regex = "<td> (. + ?) </Td> ";
Pattern pattern = Pattern. compile (regex );
Matcher matcher = pattern. matcher (str );
While (matcher. find ()){
System. out. println (matcher. group (1). trim ());
        }          
    }  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.