Java Study Notes 21 (String supplement: Regular Expression), learning notes string
Just like the re module of python, there are some differences between the regular expressions of Java and Python. Here is a brief introduction. For details, refer to other articles on the Inte
in lowercase **/ Public Static FinalString lower_letter_regexp = "^[a-z]+$"; /*** * matches a string consisting of a number and 26 English letters **/ Public Static FinalString letter_number_regexp = "^[a-za-z0-9]+$"; /*** * matches a string consisting of a number, 26 letters or underscores **/ Public Static FinalString letter_number_underline_regexp = "^//w+$"; /*** Case-sensitive formal expression batching * *@paramSource * Batch-source
When Word transforms HTML, it leaves a lot of formatting, some formatting is not what we need, however, these formats are more than the actual content of the article, seriously affect the loading speed of the page, so you need to find a good solution to the redundant format to remove. There are many regular expressions on the web that remove the JS version of Word redundancy, only the Java version of the
Import java. util. arraylist;
Import java. util. RegEx. matcher;
Import java. util. RegEx. pattern;
Public class test {Public static void main (string [] ARGs ){Getstrings (); // use a regular expression to obtain the specified content in the specified string.System. Out. p
Regular expressions usually in the use of string processing time is more commonly used, the individual feel that do not need to deliberately to understand, with the words to take out the document to check the good, the following to a link
Http://www.php100.com/manual/Javascript/html/jsgrpRegExpSyntax.htm
This is a regular expression of the document,
. (COM/CN) is an indefinite number of2. Regular expression: String regx = "\\[email protected]\\w{2,6} (\.[ a-za-z]{2,3}) + ";Analytical:\\w: all letters and numbers; +: The front appears 1 or more times; \\w{2,6}: \\w can only show 2-6\. : ‘.’ this character; [A-za-z]: all the letters; {2,3}: There are only 2-3 letters in front,(\. [A-za-z] {2,3}) +: ' + ' before content appears 1 or more timesAttention:A:
Regular Expressions: ^ ([0-9]+) $, ^: match starts with 0-9, [0-9]: matches 0-9 digits, +: matches at least one number, $: match ends with a number/*** Regular Expression: Verify string number * Two ways: *1.pattern.matcher (Number.trim ()). Find () *2.pattern.matches (Numberregexp,number.trim ()) **/ Public Static BooleanMatchnumber (String number) {Booleanresul
/** * * @author Zen Johnny * @date April 29, 2018 PM 4:51:08 * */package Demo.regex;import Java.util.regex.matcher;import J Ava.util.regex.pattern;public class Regexgetdemo {public static void Getdemo (string string, string regex) {//step1: Encapsulates a rule into an object, pattern pattern = pattern.compile (regex),//STEP2: Associate a regular object with the string to extract, get a match (engine) object Matcher Matcher = Pattern.matcher (string);
Implementation ideas:
1. Use a java.net. url object to bind a webpage address on the network
2. Obtain an httpconnection object through the openconnection () method of the java.net. url object.
3. Use the getinputstream () method of the httpconnection object to obtain the input stream object inputstream of the network file.
4. read each row of data in the stream cyclically, and use the regular expression
Turn from: http://blog.csdn.net/harryhuang1990/article/details/11888293
In the text analysis of the time we often need to filter out the stop words, punctuation and so on, this article to explain how to identify and delete all the punctuation in the text. Here are three feasible regular expression scenarios, children's shoes try it ^_^
[Java]View plain Copy (1)
The regular expression defines the link:Http://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html#sumApplication Examples:
Count the number of words in a Java string
public class Nn {public static void Main (string[] args) {String str= "This is a process";System.out.println (Str.split ("\\s+")
I recently learned Java regular expressions, but I have to writeProgramOnly. It is inconvenient, so I made a simple tool.
I am playing on my own, with limited levels and a very simple interface.
It looks like this:
After entering the regular expression and the text to be matched, click the matcher button
results or I,the pattern of the x* has been matched with the corresponding characters in text, the next pattern needs to be matched, so the pattern of x* removed II,the pattern of the x* with the text of the current letter match completed, the next text needs to be matched, so the current results and text minus one of the results of the combinationb, other conditions directly to the text and pattern each cut one, with the current comparison results together to return.Q: Why does the cur
introduction: This problem is more complex, boundary conditions are more, in order to facilitate the review, Collation. also, because C and Java have different operations for strings, there are changes to the Code.title: please implement a function to match the containing '. ' And the regular expression of ' * '. The characters in the pattern '. ' Represents any
position, the next one to determine if there is a ' * ' unit to match, matching correct removal of the matched part will be the rest of the recursive, the mismatch returns false.
Java implementations:1 Public classSolution {2 Public BooleanIsMatch (String s, String p) {3 if(P.length () ==0){4 returnS.length () ==0;5 }6 Else if(S.length () ==0) {7 if(P.length () >1p.charat (1) = = ' * ')return
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.