小编cod*_*.me的帖子

使用正则表达式,提取可能包含嵌套引号的带引号的字符串

我有以下字符串:

'Well, I've tried to say "How Doth the Little Busy Bee," but it all came different!' Alice replied in a very melancholy voice. She continued, 'I'll try again.'
Run Code Online (Sandbox Code Playgroud)

现在,我想提取以下引号:

1. Well, I've tried to say "How Doth the Little Busy Bee," but it all came different!
2. How Doth the Little Busy Bee,
3. I'll try again.
Run Code Online (Sandbox Code Playgroud)

我尝试了以下代码,但没有得到我想要的。该[^\1]*不会按预期工作。还是其他地方的问题?

import re

s = "'Well, I've tried to say \"How Doth the Little Busy Bee,\" but it all came …
Run Code Online (Sandbox Code Playgroud)

python regex

5
推荐指数
1
解决办法
3456
查看次数

Joomla内容编辑调用堆栈和URL路由

我正在使用Joomla 3.x CMS.我启用了SEO.我也在路由URL,以便隐藏文章ID,类别和类别ID.因此,具有别名的典型文章my-alias将具有URL : http://localhost/my-alias. 我在方法中的系统插件中进行此路由onAfterInitialise().确保系统中的所有别名都是唯一的.现在,当正在查看文章时,任何有权访问的人都会看到如下编辑网址:http://localhost/my-alias?task=article.edit&return=someValidToken.这也正确地路由到要编辑的实际文章.

查看文章时,用户/浏览器不会看到文章ID(根据需要).编辑时,用户/浏览器会看到文章ID(不是我想要的).也就是说,当用户单击编辑链接时,浏览器会加载编辑表单,并且用户会看到以下URL:http://localhost/edit-article?view=form&layout=edit&a_id=1002&return=someValidToken其中1002是文章ID.

以下是来自的代码段onAfterInitialise():

if (isset($query['task']) && $query['task']=='article.edit') {
    // TODO Hide this change from the user/browser
    JFactory::getApplication()->input->set('view', 'form');
    JFactory::getApplication()->input->set('layout', 'edit');
    JFactory::getApplication()->input->set('a_id', $articleId);
}
else {
    JFactory::getApplication()->input->set('option', 'com_content');
    JFactory::getApplication()->input->set('view', 'article');
    JFactory::getApplication()->input->set('id', $articleId);
}
JFactory::getApplication()->input->set('Itemid', 111); // map to dummy item in hidden menu with alias edit-article
Run Code Online (Sandbox Code Playgroud)

我想知道如何解决这个问题.通过Joomla框架了解呼叫流程将有所帮助.

joomla joomla3.0

5
推荐指数
0
解决办法
132
查看次数

在 Python 中安装 re2 模块失败

i686-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv
-O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c src/re2.cpp -o build/temp.linux-i686-2.7/src/re2.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
src/re2.cpp:201:29: fatal error: re2/stringpiece.h: No such file or directory
 #include "re2/stringpiece.h"
                             ^
compilation terminated.
error: command 'i686-linux-gnu-gcc' failed with exit status 1
Run Code Online (Sandbox Code Playgroud)

我以前做过 sudo apt-get install python-dev

python

3
推荐指数
1
解决办法
6741
查看次数

标签 统计

python ×2

joomla ×1

joomla3.0 ×1

regex ×1