Category:Regular Expression

  • PHP regular expressions commonly used in the introduction and application example code

    Time:2021-5-9

    More comprehensive examples can be referred toCollection and collation of the most commonly used PHP regular expressionshttps://www.jb51.net/article/14049.htm PHP regular expression summaryhttps://www.jb51.net/article/19831.htm Several skills of using PHP regular expressionhttps://www.jb51.net/article/19832.htm The following content is commonly used in PHP regular, regular is a general syntax, you can download more comprehensive regular online, to provide learning!Functions: segmentation, matching, search, […]

  • Several common methods of ASP regular expression (execute, test, replace)

    Time:2021-5-8

    Regexp is to create regular objects.For example:Set regEx = New RegExp Regex. Pattern is used to set regular patterns,For example:regEx.Pattern =”/d+” Regex. Ignorecase = true ‘sets whether case sensitiveRegex. Global = true ‘sets full availability. Regexp has three methods: execute, test and replace. The test method performs a regular expression search on the specified string […]

  • Reverse pre search in regular expressions

    Time:2021-5-7

    In the past, most of the applications are forward pre search. In other words, there are specific content restrictions on the right side of the search content, such as the following example: Copy codeThe code is as follows: var str3 = ‘CPU: Intel Core2 5200; Memory: 2G;OS: Ubuntu 9.04’; var reg3 = /Memory\:\s+(.*(?=\;OS\:))/gim; str3.match(reg3); alert(RegExp.$1); […]

  • Reverse pre search in regular expressions (2)

    Time:2021-5-6

    The code is: Copy codeThe code is as follows: //The purpose of the program is to remove the domain name in the image pathvar str = ‘<img src=”https://imgs.developpaper.com/imgs/logo.gif”>’; var reg1 = /(\<img)(.*(?=(http|https)\:\/\/))((http|https)\:\/\/[^\/]*)/gim; 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 multiple domain names, […]

  • JS common regular expression form validation code

    Time:2021-5-4

    Use of regular expressions brief introduction In short, regular expressions are a powerful tool for pattern matching and replacement. Its functions are as follows:A pattern of the test string. For example, you can test an input string to see if there is a phone number pattern or a credit card number pattern in the string. […]

  • JS common regular expression form validation code

    Time:2021-5-4

    Use of regular expressions brief introduction In short, regular expressions are a powerful tool for pattern matching and replacement. Its functions are as follows:A pattern of the test string. For example, you can test an input string to see if there is a phone number pattern or a credit card number pattern in the string. […]

  • A regular expression replacing directory structure to increase directory

    Time:2021-5-3

    The following operations need to be solved:There are multiple shtml files with connection addresseshttps://www.jb51.net/fgdf/222/1234.shtml https://www.jb51.net/tyty/333/456456.shtml https://www.jb51.net/tyry/789/fsdfsfs.shtml Now I want to add the directory name Inc to the connection address of these. Shtml files, that is, tohttps://www.jb51.net/fgdf/222/inc/1234.shtml https://www.jb51.net/tyty/333/inc/456456.shtml Solution: in general, EDITPLUS and other regular expression support software is OKFind target: Copy codeThe code is as […]

  • JavaScript text box verification code based on regular expression

    Time:2021-5-2

    1, cannot be empty <input   Type = “text” onblur = “if (this. Value. Replace (/ ^ + | + $/ g, ‘) =’) alert (‘cannot be empty ‘)” > “ 2. Only English and numbers can be input< input onblur = “if (/ [^ 0-9a-zA-Z] / g.test (value)) alert (‘wrong ‘)” ><input onkeyup=”value=value.replace(/[^0-9a-zA-Z]/g,”)”/><input type=”text” […]

  • Function of extracting hyperlink URL from web page by PHP regular expression

    Time:2021-5-1

    Copy codeThe code is as follows: function match_links($document) { preg_match_all(“‘<\s*a\s.*?href\s*=\s*([\”\’])?(?(1)(.*?)\\1|([^\s\>]+))[^>]*>?(.*?)</a>’isx”,$document,$links); while(list($key,$val) = each($links[2])) { if(!empty($val)) $match[‘link’][] = $val; } while(list($key,$val) = each($links[3])) { if(!empty($val)) $match[‘link’][] = $val; } while(list($key,$val) = each($links[4])) { if(!empty($val)) $match[‘content’][] = $val; } while(list($key,$val) = each($links[0])) { if(!empty($val)) $match[‘all’][] = $val; } return $match; } The main problem is regular, the […]

  • ASP hyperlink and HTML function regular expression revision

    Time:2021-4-30

    Filter hyperlinks Copy codeThe code is as follows: Function RegRemoveHref(HTMLstr) Set ra = New RegExp ra.IgnoreCase = True ra.Global = True ra.Pattern = “<A[^>]+>(.+?)<\/A>” RegRemoveHref = ra.replace(HTMLstr,”$1″) END Function Filter all HTML code Copy codeThe code is as follows: Function RemoveHTML(strHTML) Dim objRegExp, Match, Matches Set objRegExp = New Regexp objRegExp.IgnoreCase = True objRegExp.Global = […]

  • JavaScript gets the regular expression of URL parameter (used to get a parameter value)

    Time:2021-4-29

    example://JavaScript parameters (multiple)var url = “B.aspx?txtA=”+document.getElementById(“txtName”).value; url +=”&txtB=”+document.getElementById(“txtAge”).value; window.open(url,’xWindow’,’width=640,height=400,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,top=250,left=430′); //B. Aspx target page Copy codeThe code is as follows: <scirpt language=’javascirpt’> <!– function GetStringValue() { String. Prototype. Getquerystring = function (name) / / name is the parameter name of the URL{ var reg = new RegExp(“(^|&|\\?)”+ name +”=([^&]*)(&|$)”), r; if (r=this.match(reg)) return unescape(r[2]); return null; […]

  • The meanings of / ISU, / is, / s followed by PHP regular expressions

    Time:2021-4-28

    I match case The dot metacharacter (.) in pattern s matches all characters, including the newline character Except for the escaped or in character class, the white space characters in X mode are completely ignored, and all the characters, including both ends, between # and the next newline character, except for the escaped or in […]