pcre
Avoiding processing special preg characters in replacement string
When using preg_replace() in PHP with strings generated at runtime, one can protect special regex characters (such as \'$\' or \'+\') in the search string by using preg_quote(). But what\'s the correc[详细]
2023-01-17 14:50 分类:问答What's the technical reason for "lookbehind assertion MUST be fixed length" in regex?
For example,the regex below will cause failure reporting lookbehind assertion is not fixed length: #(?<!(?:(?:src)|(?:href))=["\\\']?)((?:https?|ftp)://[^\\s\\\'"<>()]+)#S[详细]
2023-01-17 09:39 分类:问答How does this PCRE pattern detect palindromes?
This ques开发者_运维问答tion is an educational demonstration of the usage of lookahead, nested reference, and conditionals in a PCRE pattern to match ALL palindromes, including the ones that can\'t b[详细]
2023-01-16 14:42 分类:问答Why will this recursive regex only match when a character repeats 2^n - 1 times?
After reading polygenelubricants\'s series of articles on advanced regular expressions techniques (particularly How does this Java regex detect palindromes?), I decided to attempt to create my own PCR[详细]
2023-01-16 10:05 分类:问答determine if regular expression only matches fixed-length strings
Is there a way of determining if the regular expression only matches fixed-length strings ? My idea would be to scan for *,+ and ? Then, some intelligent logic would be required to to look for {m,n} w[详细]
2023-01-15 01:40 分类:问答Extract numbers from text with regular expression
I am trying to extract 1 and 125 from this text开发者_如何学编程 with PHP: preg_match(\"/^(?P<digit>\\d+)/\", \"1 Foo ($125)\",$m)[详细]
2023-01-14 19:32 分类:问答Greedy Regex Matching
I\'m trying to match a string that looks something like this: <开发者_运维百科;$Fexample text in here>>[详细]
2023-01-14 10:38 分类:问答PHP mb_ereg_replace not replacing while preg_replace works as intended
I am trying to replace in a string all non word characters with empty string expect for spaces and the put together all multiple spaces as one single space.[详细]
2023-01-14 02:34 分类:问答Optimized regex for N words around a given word (UTF-8)
I\'m trying to find an optimized regex to return the N words (if available) around another one to build a summary. The string is in UTF-8, so the definition of \"words\" is larger than just [a-z]. The[详细]
2023-01-13 23:20 分类:问答Eregi to preg_replace change for php 5.3 compatibility
I have this line in one of my scripts and its throwing a deprec开发者_运维百科ated error. eregi_replace( \'\\.([a-z]{3,4})$\', \"-{$width}x{$height}.\\\\1\", $src );[详细]
2023-01-12 18:38 分类:问答