pcre

PCRE issue when setting up WSGI application

青春壹個敷衍的年華 提交于 2021-02-07 01:55:05
问题 I am working with Ubuntu 16.04.2 LTS. I have been following a guide How To Set Up uWSGI and Nginx to Serve Python Apps on Ubuntu 14.04. Once I have set up the virtualenv I follow the instructions: pip install uwsgi You can verify that it is now available by typing: uwsgi --version If it returns a version number, the uWSGI server is available for use. However when I do this I get: uwsgi: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or

Why does this preg_replace call return NULL?

二次信任 提交于 2021-02-05 09:16:06
问题 Why does this call return NULL? Is the regex wrong? With the test input it doesn't return NULL. The docs say NULL indicates an error but what error could it be? $s = hex2bin('5b5d202073205b0d0a0d0a0d0a0d0a20202020202020203a'); // $s = 'test'; $s = preg_replace('/\[\](\s|.)*\]/s', '', $s); var_dump($s); // PHP 7.2.10-1+0~20181001133118.7+stretch~1.gbpb6e829 (cli) (built: Oct 1 2018 13:31:18) ( NTS ) 回答1: Your regex is causing catastrophic backtracking and causing PHP regex engine to fail. You

m regex pattern modifiers

女生的网名这么多〃 提交于 2021-02-05 08:38:32
问题 $subject = "SIverygood \n SIverygood\n"; $pattern = '/^SI/m'; preg_match_all($pattern, $subject, $matches2,PREG_OFFSET_CAPTURE); var_dump($matches2); I am unable to understand m and s modifier. I want to get SI at the beginning of every newline. I do it for practise purpose to understand the m and s modifier. The above example just return first SI . But i want both. 回答1: The m is a multi-line modifier which will makes the start anchor matches the start of each line instead of whole of your

m regex pattern modifiers

爷,独闯天下 提交于 2021-02-05 08:38:06
问题 $subject = "SIverygood \n SIverygood\n"; $pattern = '/^SI/m'; preg_match_all($pattern, $subject, $matches2,PREG_OFFSET_CAPTURE); var_dump($matches2); I am unable to understand m and s modifier. I want to get SI at the beginning of every newline. I do it for practise purpose to understand the m and s modifier. The above example just return first SI . But i want both. 回答1: The m is a multi-line modifier which will makes the start anchor matches the start of each line instead of whole of your

Parse parameters and values of smarty-like string in PHP

╄→гoц情女王★ 提交于 2021-02-05 08:00:48
问题 I'm trying to create simmiliar parser like smarty. For very small parts of code, and don't want to implement huge smarty-like parser. What I came up with is: (?:([a-zA-Z0-9]+)=(?:([^\v '"]+)|"(.*?)"|'(.*?)')|([a-zA-Z0-9]+)) On https://regex101.com/r/l5FI5f/2/ it looks fine. Every match is either 1 or 2 entries + full match. When I copy PHP code, things look different... array (size=5) 0 => string 'xddss='asdasda'' (length=15) 1 => string 'xddss' (length=5) 2 => string '' (length=0) 3 =>

Strange result of using asterisk * quantifier

南笙酒味 提交于 2021-02-05 08:00:32
问题 I am trying to practice asterisk * quantifier on a simple string, but while i have only two letters, the result contains a third match. <?php $x = 'ab'; preg_match_all("/a*/",$x,$m); echo '<pre>'; var_dump($m); echo '</pre>'; ?> the result came out: array(1) { [0]=> array(3) { [0]=> string(1) "a" [1]=> string(0) "" [2]=> string(0) "" } } As i understand it first matched a then nothing matched when b, so the result should be array(1) { [0]=> array(2) { [0]=> string(1) "a" [1]=> string(0) "" }

Matching Unicode letter characters in PCRE/PHP

不打扰是莪最后的温柔 提交于 2021-01-29 06:36:11
问题 I'm trying to write a reasonably permissive validator for names in PHP, and my first attempt consists of the following pattern: // unicode letters, apostrophe, hyphen, space $namePattern = "/^([\\p{L}'\\- ])+$/"; This is eventually passed to a call to preg_match() . As far as I can tell, this works with your vanilla ASCII alphabet, but seems to trip up on spicier characters like Ă or 张. Is there something wrong with the pattern itself? Perhaps I'm expecting \p{L} to do more work than I think

Regex Recursion: Nth Subpatterns

邮差的信 提交于 2021-01-27 13:44:07
问题 I'm trying to learn about Recursion in Regular Expressions, and have a basic understanding of the concepts in the PCRE flavour. I want to break a string: Geese (Flock) Dogs (Pack) into: Full Match: Geese (Flock) Dogs (Pack) Group 1: Geese (Flock) Group 2: Geese Group 3: (Flock) Group 4: Dogs (Pack) Group 5: Dogs Group 6: (Pack) I know neither regex quite does this, but I was more curious as to the reason why the the first pattern works, but the second one doesn't. Pattern 1: ((.*?)(\(\w{1,}\)

Compiling pcre 8.32 on AIX 6.1 64 bit

╄→гoц情女王★ 提交于 2021-01-27 12:43:57
问题 I am trying to configure and make pcre using below command ./configure CC="gcc" CFLAGS="-maix64" CXX="gcc" CXXFLAGS="-maix64" LDFLAGS="-L/usr/ccs/bin -maix64" --disable-cpp --prefix=/usr/local/share/bld/pcre configure works fine: pcre-8.32 configuration summary: Install prefix .................. : /usr/local/share/bld/pcre C preprocessor .................. : gcc -maix64 -E C compiler ...................... : gcc -maix64 C++ preprocessor ................ : gcc -maix64 -E C++ compiler .........

Why does using the u and i modifiers cause one version of a pattern to take ~10x more steps than another?

主宰稳场 提交于 2020-12-15 04:55:16
问题 I was testing two almost identical regexes against a string (on regex101.com), and I noticed that there was a huge difference in the number of steps that they were taking. Here are the two regexes: (Stake: £)(\d+(?:\.\d+)?) (winnings: £)(\d+(?:\.\d+)?) This is the string I was running them against (with modifiers g , i , m , u ): Start Game, Credit: £200.00game num: 1, Stake: £2.00Spinning Reels:NINE SEVEN KINGKING STAR ACEQUEEN JACK KINGtotal winnings: £0.00End Game, Credit: £198Start...