需要RE的帮助 [英] need help of RE
本文介绍了需要RE的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨所有
a字符串如
"(word1&(Word2 | woRd3))"
如何使用re将其分割为
[''word1'',''word2'',''word3'']
hi all
a string like
"(word1 & (Word2|woRd3))"
how can i use the re to split it to
[''word1'', ''word2'', ''word3'']
推荐答案
2005年5月29日上午12:39,cheng写道:
On May 29, 2005, at 12:39 AM, cheng wrote:
大家好吧
(word1&(Word2 | woRd3))"
我怎样才能使用re来将它分成
[''word1'',''word2'',''word3'']
hi all
a string like
"(word1 & (Word2|woRd3))"
how can i use the re to split it to
[''word1'', ''word2'', ''word3'']
你能不能更多确切的字符串是什么样的?是吗?
字面上包含字符''&''和''|''?如果是这样,只需分成
吧。
- Elliot Temple
http://www.curi.us/
---
[此E-通过Declude Virus扫描病毒的邮件]
Could you be more exact about what the string is like? Does it
literally contain the characters ''&'' and ''|'' ? If so, just split at
them.
-- Elliot Temple
http://www.curi.us/
---
[This E-mail scanned for viruses by Declude Virus]
对不起,我的engilsh不太好,
字符串不仅包含''&''和''|''而且它可以是任何
i只想分开整个单词在字符串里面
im sorry, my engilsh is not vell well,
the string not only contain ''&'' and ''|'' and it can be anyting
i just want to split out the "whole word" inside the string
我试试
query = query.lower()
打印re.split(r''\ +',theString)
reslut是:
['''',''word1 '',''word2'',''word3'','''']
如何修复这个声明才能获得
[''word1'',''word2'',''word3'']
i try
query = query.lower()
print re.split(r''\W+'',theString)
the reslut is :
['''', ''word1'', ''word2'', ''word3'', '''']
how can i fix the statment to get
[''word1'', ''word2'', ''word3'']
这篇关于需要RE的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文