Regular expression examples

2011-05-25  来源:本站原创  分类:Web  人气:96 

Phone number regular expression (support phone number area code, 3-4 ,7-8 direct-dial number, 1-4 ext)
((\ D {11 })|^(( \ d {7,8}) | (\ d {4} | \ d {3}) - (\ d {7,8}) | (\ d {4 } | \ d {3}) - (\ d {7,8}) - (\ d {4} | \ d {3} | \ d {2} | \ d {1}) | (\ d {7 , 8}) - (\ d {4} | \ d {3} | \ d {2} | \ d {1 }))$)

Match format:
11 mobile phone number
3-4 7-8-bit code number, 1-4 live extension, such as :12345678901,1234 -12345678-1234

"^ \ D + $" / / non-negative integers (positive integers + 0)
"^ [0-9] * [1-9] [0-9] * $" / / a positive integer
"^((- \ D +) | (0 +))$" / / non-positive integer (negative integer + 0)
"^ - [0-9] * [1-9] [0-9] * $" / / negative integers
"^ -? \ D + $" / / integer
"^ \ D + (\. \ D +)?$" / / non-negative floating point numbers (positive float + 0)
"^(([ 0-9] + \. [0-9] * [1-9] [0-9 ]*)|([ 0-9] * [1-9] [0-9] * \ . [0-9 ]+)|([ 0-9] * [1-9] [0-9 ]*))$" / / are floating point
"^((- \ D + (\. \ D +)?)|( 0 + (\ .0 +)?))$" / / floating-point non-positive (negative float + 0)
"^(-(([ 0-9] + \. [0-9] * [1-9] [0-9 ]*)|([ 0-9] * [1-9] [0-9] * \. [0-9 ]+)|([ 0-9] * [1-9] [0-9 ]*)))$" / / negative float
"^(-? \ D +) (\. \ D +)?$" / / floating point
"^ [A-Za-z] + $" / / by the 26 English letters of the string
"^ [AZ] + $" / / by the 26 English letters uppercase a string
"^ [Az] + $" / / by the 26 English letters lowercase a string
"^ [A-Za-z0-9] + $" / / 26 by the numbers and a string of letters
"^ \ W + $" / / by the numbers, 26 English letters or underscore a string
"^ [\ W-] + (\. [\ W-]+)*@[ \ w-] + (\. [\ W-]+)+$" / / email address
"^ [A-zA-z ]+://( \ w + (- \ w +)*)( \. (\ W + (- \ w +)*))*( \? \ S *)?$" / / url
/ ^ 13 \ d {9} $ / gi phone number regular expression
public static bool IsValidMobileNo (string MobileNo)
{
const string regPattern = @ "^ (130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139) \ d {8} $";
return Regex.IsMatch (MobileNo, regPattern);
}
Regular expressions - Verify phone number: 13 [0-9] {9}
Achieving mobile phone number with 86 or 86 before the case: ^ ((\ +86) | (86))? (13) \ d {9} $
Phone number and phone number and to verify: (^ (\ d {3,4} -)? \ D {7,8 })$|( 13 [0-9] {9})
Extraction of information in the Web link: (h | H) (r | R) (e | E) (f | F) *= *('|")?( \ w | \ \ | \ / | \.) + ('|"| *|>)?
Extraction of information in the e-mail address: \ w +([-+.] \ w +) * @ \ w +([-.] \ w +) * \. \ W +([-.] \ w +) *
Extraction of information in the image link: (s | S) (r | R) (c | C) *= *('|")?( \ w | \ \ | \ / | \ .)+('|"| *|>)?
The IP address of extracting information: (\ d +) \. (\ D +) \. (\ D +) \. (\ D +)
Chinese extract information in the mobile phone number: (86) * 0 * 13 \ d {9}
Chinese extract information in the fixed telephone number: (\ (\ d {3,4} \) | \ d {3,4} - | \ s)? \ D {8}
Chinese extract information phone number (including mobile and fixed phone): (\ (\ d {3,4} \) | \ d {3,4} - | \ s)? \ D {7,14}
Chinese extract information in the Zip Code: [1-9] {1} (\ d +) {5}
Chinese extract information in the ID number: \ d {18} | \ d {15}
Extraction of information in the integral: \ d +
Extraction of information in the floating-point (ie decimal ):(-? \ d *) \.? \ D +
Extract information in any number: (-? \ D *) (\. \ D +)?
Chinese extract information in the string: [\ u4e00-\ u9fa5] *
Extraction of information in the double-byte string (character): [^ \ x00-\ xff] *

相关文章
  • Regular expression examples Xiangjie + GWT-EXT 2010-06-22

    Regular expression examples Xiangjie + GWT-EXT A first look at the basic syntax of regular expressions: 1.1 General characters: letters, numbers, characters, underscores and no special significance is defined punctuation 1.2 Simple escaped characters

  • Android regular expression examples 2010-10-12

    editText the use of regular expressions check whether the rules of the input import Android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; /** * Class which shows how to

  • _01 Turn regular expression examples 2010-11-14

    The use of regular expressions Java keywords: java regular expression string In Java, we have to find a given string whether it is necessary to find a character or a sub-string, or split a string, or string of characters to be replaced / removed, gen

  • The basis of the regular expression examples 2010-11-16

    package com.hzp.reg; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Reg1 { public static void main (String [] args) { String s1 = "123456789"; String s2 = "abcdefg"; String s3 = "12ab"; String s4

  • Regular expression examples 2011-05-25

    Phone number regular expression (support phone number area code, 3-4 ,7-8 direct-dial number, 1-4 ext) ((\ D {11 })|^(( \ d {7,8}) | (\ d {4} | \ d {3}) - (\ d {7,8}) | (\ d {4 } | \ d {3}) - (\ d {7,8}) - (\ d {4} | \ d {3} | \ d {2} | \ d {1}) | (\

  • 10 Java Regular Expression Examples 2012-12-13

    1. Username Regular Expression Pattern ^[a-z0-9_-]{3,15}$ ^ # Start of the line [a-z0-9_-] # Match characters and symbols in the list, a-z, 0-9 , underscore , hyphen {3,15} # Length at least 3 characters and maximum length of 15 $ # End of the line 2

  • Java Regular Expression Application summary (change) 2010-03-29

    First, an overview of A regular expression is Java Dealing with strings, the text of the important tool. Java The processing of regular expressions in the following two two classes: java.util.regex.Matcher pattern class: used to indicate a compiled r

  • Java Regular Expression Application Summary 2010-03-29

    Java Regular Expression Application Summary First, an overview of Regular expressions are Java handling strings, the text of the important tool. Java on the handling of regular expressions in the following two two classes: java.util.regex.Matcher pat

  • Regular expression related 2010-02-25

    Transfer from Visual Studio Development Center http://msdn.microsoft.com/zh-cn/library/28hw3sce% 28VS.80% 29.aspx Regular Expressions Introduction <!----> <! - Content type: DocStudio. Transform: devdiv2mtps.xslt .--> These chapters introduce

  • Collection of PHP regular expressions examples 2010-03-25

    2008-04-13 15:32 / / intercept the middle of the string method preg_match ('/(?: ello )(.*)/', 'hello biafra', $ match); print_r ($ match); Array ( [0] => ello biafra [1] => biafra ) preg_match ('/ (ello )(.*)/',' hello biafra ', $ match); print_r (

  • Java regular expression syntax 2010-07-01

    Regular expression syntax Regular expression is a text mode, including ordinary characters (for example, a to z between the letters) and special characters (called "meta characters"). Model described in the search text to match one or more strin

  • JAVA regular expression syntax (switch) 2010-07-09

    JAVA regular expression syntax (switch) Regular expression syntax Regular expression is a text mode, including ordinary characters (for example, a to z between the letters) and special characters (called "meta characters"). Model described in th

  • JavaScript's regular expression parsing 2010-07-12

    Regular expression is a character model describing the object. JavaScript's RegExp object and String object is defined using regular expressions to perform powerful pattern matching and text search and replace functions. In JavaScript, regular expres

  • [Reprint] regular expression 2010-07-27

    Reprint address http://www.javaeye.com/topic/719950 Regular Expressions / / Check if all the numbers function isDigit (s) ( var patrn = / ^ [0-9] (1,20) $ /; if (! patrn.exec (s)) return false return true ) / / Check login name: Enter only 5-20 month

  • JS regular expression sample code 2010-08-01

    <html> <head> <title> JS regular expressions </ title> <script language="javascript" type="text/javascript"> / / JavaScript regular expression application example function regexSample () ( / / Instance of

  • Regular Expression Object 2010-08-16

    This object contains the regular expression patterns and show how to apply the model sign. Syntax 1 re = / pattern / [flags] Syntax 2 re = new RegExp ("pattern", ["flags"]) Parameter re Required. Will be assigned to a regular expressio

  • js regular expression syntax 2010-09-24

    Regular expression syntax A regular expression is the general character (such as characters a to z) and special characters (called metacharacters) composed of text mode. The model describes the main characters in the search to be matched when one or

  • Regular Expression Reference 2010-11-08

    / / Check whether all the numbers function isDigit (s) { var patrn = / ^ [0-9] {1,20} $ /; if (! patrn.exec (s)) return false return true } / / Check login name: Enter only 5-20 with a letter, can be a string with digital ,"_","." Java

  • JS regular expression (reproduced) under good learning 2011-04-29

    / / Check whether all the numbers function isDigit (s) { var patrn = / ^ [0-9] {1,20} $ /; if (! patrn.exec (s)) return false return true } / / Check login name: Enter only 5-20 with a letter, can be a string with digital ,"_","." func

  • java commonly used examples of regular expression matching Daquan 2010-09-06

    java commonly used example of the matching regular expression matching collection of Chinese characters Daquan regular expression: [\ u4e00-\ u9fa5] Matching double-byte characters (including Chinese characters included): [^ \ x00-\ xff] Application: