Tag:Reverse pre search

  • Implementation of reverse pre search in regular expressions

    Time:2021-6-9

    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: var str3 = ‘CPU: Intel Core2 5200; Memory: 2G; OS: Ubuntu 9.04’; var reg3 = /Memory\:\s+(.*(?=\; OS\:))/gim; str3.match(reg3); alert(RegExp.$1); // The result is […]

  • 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, […]