Category : pcre

Assume the following string: @twitter @handles @hello Using the code below, I can replace the strings and generate links preg_replace( ‘/(?:^|[^>])(@’ . $data->entities->user_mentions[$i]->screen_name . ‘)/’, ‘<a href="https://twitter.com/’ . $data->entities->user_mentions[$i]->screen_name . ‘">@’ . $data->entities->user_mentions[$i]->screen_name . ‘</a>’, $data->text ); but the code above replaces group 0, not group 1 alot of questions on stackoverflow show people how ..

Read more

Have seen simple preg_replace (or even just str_replace) examples of adding <span class="highlight"> around an array of searched words. But a lot of search queries will search for terms in the order written: Search: blue shoes MySQL query: SELECT * FROM my_table WHERE title LIKE ‘%blue%shoes%’ Matches: MATCH – "Don’t step on my blue suede ..

Read more

I tried to import data from XML file using the importDump utility… [email protected]:/var/www/html/mediawiki-1.36.1# php ./maintenance/importDump.php mrwiki-latest-pages-articles-multistream.xml Got this error: MWException from line 2108 of /var/www/html/mediawiki-1.36.1/includes/parser/Parser.php: PCRE needs to be compiled with –enable-unicode-properties in order for MediaWiki to function I downloaded the source code of PCRE and run make / make install but that did not ..

Read more

I’m trying to get all text but not if it’s inside inline code (`) or code block(“`). My regex is working fine but the last text doesn’t match and I don’t know why. My current regex: (.*?)`{1,3}(?:.*?)`{1,3}(.*?) You can check out the result here: https://regex101.com/r/lYQnUJ/1/ Maybe anybody has an idea how to solve that problem. ..

Read more