To match a slash inside a regular expression, you need to use 4 slashes:
Java code
Import Java.util.regex.Matcher;
Import Java.util.regex.Pattern;
public class Test {
/**
* @param args */public
static void Main (string[] args) {
//TODO Auto-generat Ed method stub
String textstring = new String ("\\\");
Pattern Pt=pattern.compile ("\\\\\");
Original: Java common regular Expression validation tool class Regexutils.javaSource code: Http://www.zuidaima.com/share/1550463379442688.htmJava Forms register a common regular expression validation tool class, a large collection of commonly used
Original: Java HTML string Regular expression using the tool classCode: http://www.zuidaima.com/share/1550463453416448.htmHTML-related Regular expression tool classes include filtering HTML tags, converting HTML tags, replacing specific HTML tags Package Com.zuidaima.common
/** * * @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);
the regular need to escape the character: ' $ ', '(', ') ', ' * ', ' + ', '. ', '[', '] ', '? ', ' \ \', ' ^ ', '{ /c10>', '} ', ' | 'Abnormal phenomenon:java.util.regex.PatternSyntaxException:Dangling Meta. Character ' * ' near index 0workaround : multibyte \ Escape for special characters. Note: Although it is possible to use [] under some conditions, the following will be reported in the case where the (, [, {range boundary start character does not
expression is capable of
You can use the compile method to compile it (after you get its matching pattern) so that it is repeated multiple times in your script.
You can also use the Compile method to change the regular expression during run time. For example, if the regular
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
Package Demo.regex;import java.util.regex.pattern;/* Regular expression: Match */public class Regexmatchesdemo {//Match mobile phone number//13xxxxx; 15xxxxxx;18xxxxxxpublic static void Checkphone (String string) {System.out.println (Pattern.matches ("1[358]\\d{9}", string));} Match Mailbox/* (0) can only be QQ mailbox/gmail mailbox/outlook Mailbox/163 mailbox One (1) Letter beginning, (3) User name part: c
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
For example (,),., |, * and other symbols of the class: String area = "(30.13206313822174, 120.4156494140625) (29.87637380707133, 120.1629638671875) (29.882327547852515, 120.50079345703125)"; int t = area. split ("\\)"). length; System. out. println (t); public string [] split (string regex) the parameter name here is regex, that is, regular expression (
Greediness (greedy type): Maximum matchX, x*, x+, X{n,} are the maximum matches. For example you want to use "In the greediness mode, the match will be as large as possible until the entire content is matched, and when the match is found to be unsuccessful, the fallback narrowing the match until the match is successfulString test = "A= ""# # #");Output: a## #abbReluctant (laziness) (barely): Minimum matchX??、 x*, x+?, X{n,}? Is the minimum match, in f
Occasionally found Dongdong, do not remember is that the Bolg. Very good article ....
§1 Dark Years
There is a string, how do I find out if there are Y and F characters? The darkest way is to:
Program 1: I know if, for statements, and Charat ().
Class test{public static void Main (String args[]) {String str= "For my money, the important thing" +"About the meeting is bridge-building";Char x= ' y ';Char y= ' f ';Boolean result=false;for (int i=0;iChar Z=str.charat (i); System.out.println (z);
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
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.