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)
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
,} ' cannot match ' o ' in ' Bob ', but can match all o in ' Foooood '. ' O{1,} ' is equivalent to ' o+ '. ' O{0,} ' is equivalent to ' o* '.{n,m} m and n are non-negative integers, where n ? When the character immediately follows any other restriction (*, +,?, {n}, {n,}, {n,m}), the matching pattern is non-greedy. The non-greedy pattern matches the searched string as little as possible, while the default greedy pattern matches as many of the searched strings as possible. For
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
if not matched, otherwise the next comparison. If the next one is ' * ', the position of the PP is moved backwards by two bits, and the SP's position is now a brute force comparison, one for each move backwards.The code is as follows:1 Public classSolution {2 Public Static BooleanIsMatch (String s, String p) {3 if(s = =NULL)4 returnp = =NULL;5 if(p = =NULL)6 returns = =NULL;7 returnHelper (s, p, 0, 0);8 }9 Private Static BooleanHelpe
// Chinese character range u4E00-u9FA5import java. util. regex. matcher; import java. util. regex. pattern;/************************ create by fzw my website: www.itstack.org * November 19, 2013 * Regular Expression ************************/public class sxtRegex01 {public static void main (String [] args) {p ("check fo
There are many expressions for verifying IP addresses using regular expressions on the Internet. You can search a large number of expressions and write them on your own. However, it is very troublesome and troublesome. It is inevitable that someone else will write a bug. I found a few tests. I don't know any bugs or even the correct IP addresses. Many of them are still vowed, as if I had tested them myself. Today, I found a
S:arr) * { $ Ts.add (s);Panax Notoginseng } -Regex= "0* (\\d+)"; the for(String s:ts) + { ASystem.out.println (S.replaceall (Regex, "$")); the } + } -}View CodeOperation Result:1 192.168.10.34 2 127.0.0.1 3 105.70.11.75 4 3.3.3.3 5 6 7 192.168.010.034 8 127.000.000.001 9 105.070.011.075 003.003.003.003 A 3.3.3.3 105.70.11.75 127.0.0.1 192.168.10.34 View CodeWhen the extra 0 is removed, the mode used is: "0* (\\d+)", so that even if all is 0, the
ImportJava.util.regex.Matcher; ImportJava.util.regex.Pattern; Importjava.util.regex.PatternSyntaxException; Public classPhoneformatcheckutils {/*** Mainland or Hong Kong numbers are available*/ Public Static BooleanIsphonelegal (String str)throwspatternsyntaxexception {returnIschinaphonelegal (str) | |Ishkphonelegal (str); } /*** Mainland Mobile phone number 11 digits, match format: first three bit fixed format + 8 digits any number * This method in the first three bit format has:
In this case, the regular expression optimization, mainly for the current commonly used NFA pattern regular expressions, in detail can be referred to: regular expression matching parsing process analysis (regular
, such as replacing all the Cos in a string with sin.
Match a single character(1) Matching plain textRegular expressions can contain plain text (or even plain text).There may be multiple matching results when matching plain text, and most of the regular expression implementations provide a mechanism for finding all of the matching results (usually returning an array).Re
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.