.
Word retrieval, but only in English
$str = ' i\ ' m a teacher ';
Preg_match_all ('/\b[a-z]+\b/i ', $str, $arr);
Print_r ($arr)
Copy content to Clipboard code:
u modifier, matching by Unicode
$str = ' You You ';
$str = Preg_replace ('/[you]/', ' You ', $str);
Echo $str; was opened, printed 4 times for You
Look at the following plus the U modifier effect, the modifier needs to encode utf-8 or it will be an error
My text is gb2312, so I want to turn it into a utf-8.
$str = Iconv (' gb2312 ', ' ut
Title: Please implement a function to match the containing '. ' and a regular expression of ' * '. The characters in the pattern '. ' Represents any one character, and ' * ' means that the preceding character can appear any time (including 0 times). In this point, a match is a string that matches all the characters of the entire pattern. For example, the string "AAA" matches the schema "A.A" and "ab*ac*a", but does not match "aa.a" and "Ab*a".
Each t
1. Base character replacement
Requirements:
Replaces a string with a number string in *
String e = "ASDLFJ328238ASLDFJLSFD32323SDFL";String reg5 = "\\d+";String newstr = E.replaceall (Reg5, "*");System.out.println (NEWSTR);
Print Result: ASDLFJ**ASLDFJLSFD**SDFL
2. Replacement of overlapping words
Requirements:
To replace a duplicate string in a string with a *
String f = "ASDLFJCCCASDFZZASFD";String Reg6 = "(.) \\1+ ";String newStr2 = F.replaceall (Reg6, "*");System.out.println (N
The number of mobile phones is now 150,153,156,158,159,157,188,189 higher.So the regular expression is as follows: string s = @ "^" (13[0-9]|15[0|3|6|7|8| 9]|18[8|9])/d{8}$ ";Validation code:
Using System; Using System.Collections.Generic; Using System.Text; Using System.Text.RegularExpressions; Using System.Windows.Forms; Namespace ConsoleApplication1 {class Program {static void Main (string[] args) {//String s = @ ' ^ (13[0-9]|15[0|3|6|8| 9])/d{8}$
Copy Code code as follows:
/**
* * author:site120
* * Function:get script part from HTML document
**/
var loadjs = function (str, delaytime)
{
var delaytime = Delaytime | | 100;
var regexp_scripttag = new RegExp ("var regexp_scriptattrib_src = new RegExp ("\\s*src?\\s*=\\s* ([^\"]+) \ "|\" ([^\ ']+) \ ' |\\s* ([^\\s]+) \\s*) "," GI ");
var arr_scripttag = null;
var arr_scriptattib = null;
var scriptdata = "";
var jslist = new Array ();
while ((Arr_scripttag=regexp_scripttag.exec
Get rid of HTML tags regular Function losehtml (CONTENTSTR)
Dim Clstemplosestr,regex
Clstemplosestr = Cstr (CONTENTSTR)
Set RegEx = New RegExp
Regex.pattern = "Regex.ignorecase = True
Regex.global = True
Clstemplosestr = Regex.Replace (Clstemplosestr, "")
Set RegEx = Nothing
losehtml = Clstemplosestr
End Function
Get rid of class in a Web page
Function Loseclasstag (CONTENTSTR)
Dim Clstemplosestr,regex
Clstemplosestr = Cstr (CONTENTSTR)
Set RegEx = Ne
We often use PHP to filter some of the features of the tags, such as filtering the link tag, filtering script tags, and so on, here is a description of the PHP filter common tags of regular expression code:
$str =preg_replace ("/\s+/", "", $str); Filter Excess return $str =preg_replace ("/
Strings: string s = "1,2,3,4,5,"
Goal: Delete the last ","
Method:
1, use the most is substring, this is also I have been used, must pay attention to the case, cloud Habitat Community Small series has been tested.
Copy Code code as follows:
var s = "1,2,3,4,5,"
S=s.substring (0,s.length-1)
alert (s);
2, the use of regular expressions to achieve
Copy Code code as follows:
var str= "A,b,c,d,"
var reg=/,
SQL parameter format for example: SELECT * from TB where nd=:nd and Yd=:yd
To convert all the parameters in the SQL statement (with colons) to data at once,
Begin
The regular expression is selected.
Originally written like this
Copy Code code as follows:
Strsql.replace (/(: \w+)/g, ("$"). Substring (1));
"$" always resolves to a string rather than a matching value
Into
Copy Code code as follows:
Strsql.replace (/(: \w+)/g,
I want to match the back of ASP that is not X and. Net.
such as: asp.net aspx asp Aspyu only need to match aspyu and ASP such a regular, I did the old meeting, also did not get out, everyone help AH
Negative pre-check:
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
This is a question I asked in the classic forum, thank Sheneyan (non-existent) moderator
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Matching the regular of the FTP address
Copy Code code as follows:
ftp://(. +?) /
The role is the smallest match, is the first/previous content
. Equivalent to \x0d and \cm.
\s
Matches any white space character, including spaces, tabs, page breaks, and so on. equivalent to [\f\n\r\t\v].
\s
Matches any non-white-space character. equivalent to [^ \f\n\r\t\v].
\ t
Matches a tab character. Equivalent to \x09 and \ci.
\v
Matches a vertical tab. Equivalent to \x0b and \ck.
\w
Matches any word character that includes an underscore. Equivalent to ' [a-za-z0-9_] '.
Feature Description: This property is a static read-only property of RegExp, which is a string that matches the detection of the regular expression described by the RegExp object, which can also be represented as a $_
Copy Code code as follows:
It is made up of 0-9,a-f. The corresponding relationship with the 10 binary is: 0-9 corresponds to 0-9; A-f corresponds to 10-15; The number of N-ary can be expressed in 0---(N-1) for more than 9 letters A-F.
Which is made up of characters: 012345679ABCDEF
The number 16 in C language must begin with 0x. For example, 0x1 represents a 16 number. and 1 represents a decimal. In addition, such as: 0xff,0xff,0x102a, and so on. The x is not case-sensitive. (Note: 0 of the 0x is the number 0, not th
Regular with duplicate 5 to 10 digits can be used with \d{5,10}
No duplicates 5 to 10 digits I thought about it, but I had to check the Internet.
There is a good version, anyway Regexbuddy test passed.
Copy Code code as follows:
^(?! \d*? (\d) \d*?\1) \d{5,10}$
For (?! ......... (......) ... \1) This form I have not studied thoroughly, have the time I really want to study carefully.
Previous example of PHP:
Copy Code code a
Pattern modifier
Pattern modifier--explain the modifiers used in regular expression patterns
Description
The following is a list of possible modifiers that are currently available in PCRE. The internal PCRE names of these modifiers are in parentheses. The blanks and line breaks in the modifier are ignored, and other characters can cause errors.
I (pcre_caseless)
If you set this modifier, the characters in the pattern will match both the uppercase an
-------------JS-----------------
Copy Code code as follows:
----------Form------------------------
Copy Code code as follows:
s
-----------Regular expression of S----------------------------
Copy Code code as follows:
Replace (/.*\/([^\/]+) \.. +/, ' $ ') get picture name
The code is:
Copy Code code as follows:
Program purpose, remove the domain name in the image path
var str = ' ';
var reg1 =/(\Str.match (REG1);
Alert (Str.replace (regexp.$4, ");
This usage is applicable when there is only one URL in the string, but if the string contains more than one domain name, for example:
Copy Code code as follows:
var str = ' Cloud Habitat Home
After the program is run, the content that is removed is the second domain n
:7 2:7 ' 3:7 4:7 ' 5:7
[ Root@yonglinux ~]# head-5 passwd |awk-f: ' {print NF} '
7
7
7
7
7
[Root@yonglinux ~]# head-5 P ASSWD |awk-f: ' {print NR} '
1
2
3
4
5
[root@yonglinux ~]# head-5 passwd |awk-f: ' {print $N F} '
/bin/bash
/sbin/nologin
/sbin/nologin
/sbin/nologin
/sbin/nologin
NF represents the number of segments, while $NF is the last, while NR is the line number.
5, the mathematical operation in awkawk can also perform mathematical operations on the values of each segment:
The following UPDATE statement executes the replace test in www.test.com with ABC
Program code
Example:
Update test SET
url= REPLACE (' www.test.com ', ' Test ', ' abc ')
Where url REGEXP www.test.com;
If in the record, there are similar
Www.test.comWww.test1.comWww.test2.com
To turn these records into Www.abc.com, execute the SQL statement as follows
Update test SET
url= REPLACE (' www.test.com ', ' Test ', ' abc ')
Where url REGEXP ' ^ (www.test) ';
is very flexible, but
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.