Category:Regular Expression

  • [PHP] common regular expression collection

    Time:2021-10-25

    Regular expressions are used in string processing, form verification and other occasions, which are practical and efficient. Some commonly used expressions are collected here for future use. Article reprinted from: http://www.phpchina.com/31423/viewspace_ 9417.html Regular expressions matching Chinese characters: [\u4e00-\u9fa5]Comment: matching Chinese is really a headache. It’s easy to do with this expression Match double byte characters […]

  • A very good regular practice JS version

    Time:2021-10-24

    The technical content is not high. The main reason is that regular is used more often. It’s too troublesome to debug the code. Just do this to try faster ~ ~ ~ give it to those friends who like regular~~~ I’m dizzy. I can’t find a few regular examples to learn for novices, so now […]

  • JS regular matching table tr

    Time:2021-10-23

    I think it’s simpler than ijao, but my brain just can’t turn…. Please have a look. <textarea id=”txt”>  <table border=1 width=”20%”>                    <tr><th>title</th><th>title2</th></tr>             <tr rs=”{id:\’section006\’}”><td>data1</td><td>data2      </td>             </tr>             <tr ><td>data1</td><td>data2</td></tr>  </table>  </textarea>  <script>  var str = document.getElementById(‘txt’).value;  alert(str);  </script> /<tr[^>]*>[\s\S]*?<\/tr>/gi, Share a function //General replacement function doRepNormal(s){ var str=s.replace(/<p><br type=”_moz”>\s*?<\/p>/ig,””); str=str.replace(/<p>\s*?<br type=”_moz”>\s*?<\/p>/ig, “”); str=str.replace(/<p>(\s|\&nbsp\;| | |\xc2\xa0)*?<\/p>/ig, “”); str=str.replace(/<p>\s*?<\/p>/ig,””); str=str.replace(/<p>&nbsp;<\/p>/ig,””); str=str.replace(/<br type=”_moz”>\n&nbsp;<\/p>/ig, “</p>”); str=str.replace(/<br type=”_moz”>\s*?<\/p>/ig, “</p>”); str=str.replace(/<br\s*?\/?>\s*?<\/p>/ig, “</p>”); […]

  • Wushang JavaScript regular exerciser

    Time:2021-10-22

    In the simple modified version, the replacement with functions cannot be completed temporarily, and the ordinary replacement is OKhttps://www.jb51.net/tools/regex_test.htm Wushang regular exerciser A regular expression consists of ordinary characters (such as characters a to Z) and special characters (calledMetacharacter)Text mode composed of. This pattern describes one or more strings to match when finding the body […]

  • JavaScript uses regular expressions to replace 1234567890 with abcdefghij

    Time:2021-10-21

    Copy codeThe code is as follows: <script> alert(‘0123456789’.replace(/(\d)/g, function ($1){return “abcdefghij”.split(“”)[$1];})); </script>

  • A regular expression that matches the shape “#100”

    Time:2021-10-20

    I want to match the shape #00 #01 #02 …………………….. #116 #117 There are more than 100 characters in total, and those beyond this range do not match, How do you write it? I hope you can give me some advice. Copy codeThe code is as follows: /^#[0-9][0-9][0-7]?/ [0-7]? It means that the last number […]

  • Another good application – regular to find replacement strings

    Time:2021-10-19

    The following code is intercepted from the source code of a web page:onClick=”MM_openBrWindow(‘../photo/nlife/sfc/pages/O’Connors_jpg.htm’,’RD’,’width=456,height=368′)” onClick=”MM_openBrWindow(‘../photo/nlife/sfc/pages/Trad’r Sam_jpg.htm’,’RD’,’width=456,height=368′)” onClick=”MM_openBrWindow(‘../photo/nlife/sea/pages/Mondo’s Beach Pub_jpg.htm’,’RD’,’width=456,height=368′)” onClick=”MM_openBrWindow(‘../photo/nlife/tam/pages/Mirage (Moet’s) _jpg.htm’,’RD’,’width=456,height=368′)” onClick=”MM_openBrWindow(‘../photo/nlife/tem/pages/Macayo’s – N Central_jpg.htm’,’RD’,’width=456,height=368′)”> onClick=”MM_openBrWindow(‘../photo/nlife/tem/pages/RT O’Sullivans_jpg.htm’,’RD’,’width=456,height=368′)” onClick=”MM_openBrWindow(‘../photo/nlife/nyc/pages/Pat O’Hurley’s Bar & Grill_jpg.htm’,’RD’,’width=456,height=368′)” Here, you need to replace the ‘batch’ in the link with ‘\. Note that there are spaces and special characters (horizontal bars, brackets, & etc.) in the link, and’ appears more than once in some places. […]

  • Regular expression application code in [ASP]

    Time:2021-10-18

    Today, when changing a B2B e-commerce system, I found that ASP is regular. Although I have used ASP for a long time, I have never used regular expressions. There is a regular function in this system, which is very good. Let me see for myself. Copy codeThe code is as follows: <%   Function RegExpTest(patrn, strng)       Dim […]

  • ASP regular expression detects functions beginning with HTTP

    Time:2021-10-17

    ‘#################################### ‘function: ishttp [STR]‘parameter: STR, string to be processed‘author: Mu Mu‘date: July 12, 2007‘description: check whether the HTTP connection address or address bar starts with HTTP‘example: <% = ishttp( http://www.alixixi.com )%>‘#################################### Function ishttp(str) Dim regEx Set regEx = New RegExp regEx.Pattern = “^(http|HTTP)[A-Za-z]{0,1}\:\/\/” ishttp = regEx.Test(str) End functionVerify that the email address meets the standards<% ‘****************************** ‘function: isEmail (strng)‘parameter: strng, email address to be verified‘author: alisisi‘date: […]

  • Regular matching percentage code under JavaScript

    Time:2021-10-16

    <script language=”javascript”>     var re = /^-?\d+%$/;     alert(re.test(‘50%’));     alert(re.test(‘-25%’));     alert(re.test(‘3a5%’)); </script>

  • JavaScript is the next regular way to restore HTML code

    Time:2021-10-15

    I saw someone in blue today   When I asked this question, I tried to write one. I think the regular replace + function method is very convenient and concise. The code is as follows: [Ctrl + a full selection note: you need to refresh the page to import external JS]

  • JS regular expression script for extracting all Chinese characters in the string

    Time:2021-10-14

    It is found on the Internet that someone has realized this function with VBScript regular expression, but the code is very factory. It is even changed to JS. A very short piece of code: [Ctrl + a full selection note: you need to refresh the page to import external JS] The key here isThe coding […]