pcre

Python Regex Negative Lookbehind

 ̄綄美尐妖づ 提交于 2020-12-04 15:58:39
问题 The pattern (?<!(asp|php|jsp))\?.* works in PCRE, but it doesn't work in Python. So what can I do to get this regex working in Python? (Python 2.7) 回答1: It works perfectly fine for me. Are you maybe using it wrong? Make sure to use re.search instead of re.match : >>> import re >>> s = 'somestring.asp?1=123' >>> re.search(r"(?<!(asp|php|jsp))\?.*", s) >>> s = 'somestring.xml?1=123' >>> re.search(r"(?<!(asp|php|jsp))\?.*", s) <_sre.SRE_Match object at 0x0000000002DCB098> Which is exactly how

Python Regex Negative Lookbehind

元气小坏坏 提交于 2020-12-04 15:55:45
问题 The pattern (?<!(asp|php|jsp))\?.* works in PCRE, but it doesn't work in Python. So what can I do to get this regex working in Python? (Python 2.7) 回答1: It works perfectly fine for me. Are you maybe using it wrong? Make sure to use re.search instead of re.match : >>> import re >>> s = 'somestring.asp?1=123' >>> re.search(r"(?<!(asp|php|jsp))\?.*", s) >>> s = 'somestring.xml?1=123' >>> re.search(r"(?<!(asp|php|jsp))\?.*", s) <_sre.SRE_Match object at 0x0000000002DCB098> Which is exactly how

Regular expression - PCRE (PHP) - word boundary (\b) and accent characters

懵懂的女人 提交于 2020-07-31 03:55:05
问题 Why does the letter é count as a word boundary matching \b in the following example? Pattern: /\b(cum)\b/i Text: écumé Matches 'cum' which is not desired. Is it possible to overcome this? 回答1: It will work, when you add the u modifier to your regex /\b(cum)\b/iu 回答2: To deal with unicode, replace \b with /(?<=^|\PL)(cum)(?=\PL|$)/i 来源: https://stackoverflow.com/questions/22068702/regular-expression-pcre-php-word-boundary-b-and-accent-characters

Regular Expressions: How to find dashes between words

前提是你 提交于 2020-07-09 06:16:11
问题 In PCRE how to find dashes between words e.g. First-file-111-222.txt This-is-the-second-file-123-456.txt And-the-last-one-66-77.txt So, the dash between First and and File (etc) Then I could replace them with a space. With ([^a-zA-Z]\d(.+)) I could select the last part (dash+nbrs) but I don't know how to mark the other dashes. == edit the idea is to use a renamer tool (supporting regular expressions) - the rename would then to result in First file-111-222.txt This is the second file-123-456

Regular Expressions: How to find dashes between words

泪湿孤枕 提交于 2020-07-09 06:13:06
问题 In PCRE how to find dashes between words e.g. First-file-111-222.txt This-is-the-second-file-123-456.txt And-the-last-one-66-77.txt So, the dash between First and and File (etc) Then I could replace them with a space. With ([^a-zA-Z]\d(.+)) I could select the last part (dash+nbrs) but I don't know how to mark the other dashes. == edit the idea is to use a renamer tool (supporting regular expressions) - the rename would then to result in First file-111-222.txt This is the second file-123-456

Regular Expressions: How to find dashes between words

眉间皱痕 提交于 2020-07-09 06:12:59
问题 In PCRE how to find dashes between words e.g. First-file-111-222.txt This-is-the-second-file-123-456.txt And-the-last-one-66-77.txt So, the dash between First and and File (etc) Then I could replace them with a space. With ([^a-zA-Z]\d(.+)) I could select the last part (dash+nbrs) but I don't know how to mark the other dashes. == edit the idea is to use a renamer tool (supporting regular expressions) - the rename would then to result in First file-111-222.txt This is the second file-123-456

trim lines and shrink whitespaces using regex for multi line string

社会主义新天地 提交于 2020-05-09 06:26:07
问题 I 'm using a php function want to create a function to trim all unnecessary white spaces from a multi line string. The regex that it's not working is the one that removes spaces at the end: // Always trim at the end. Warning: this seems to be the costlier // operation, perhaps because looking ahead is harder? $patterns[] = ['/ +$/m', '']; Given the following string from a textarea: first line... abc //<-- blank space here second is here... def //<-- blank space here //<-- blank space here

regex101.com VS myserver - different results

微笑、不失礼 提交于 2020-04-30 07:30:29
问题 I get differents results, anyone could tell me why? RegExp: [0-9]+(?:\s){0,10}(?:\r?\n?)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}),([0-9]{1,3}) --> ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}),([0-9]{1,3})(?:\s){0,10}(?:\r\n|\n|\r){1}(.*\r?\n?.*\r?\n?.*)(?:\n|\r)(?:\n|\r) On Regex101 I use 'gm' modifiers. On PHP I use: preg_match_all($this->Pattern, $txt, $matches, PREG_SET_ORDER); Regex101 result (look match 4 - this is correct. Pattern get only empty line, without any "time line text"): MATCH 1 1. [2

Nginx 服务器搭建--亲自

时光毁灭记忆、已成空白 提交于 2020-04-06 23:51:14
将nginx-1.8.0.tar.gz拷贝至linux服务器。 解压: tar -zxvf nginx-1.8.0.tar.gz cd nginx-1.8.0 1、 configure ./configure --help查询详细参数(参考本教程附录部分:nginx编译参数) 参数设置如下: ./configure \ --prefix=/usr/local/nginx \ --pid-path=/var/run/nginx/nginx.pid \ --lock-path=/var/lock/nginx.lock \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --with-http_gzip_static_module \ --http-client-body-temp-path=/var/temp/nginx/client \ --http-proxy-temp-path=/var/temp/nginx/proxy \ --http-fastcgi-temp-path=/var/temp/nginx/fastcgi \ --http-uwsgi-temp-path=/var/temp/nginx/uwsgi \ --http-scgi-temp