由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Linux版 - Regular Expression question: how to enumerate all matches? (转载)
相关主题
请教一个Python问题, 怎么读出一个data structure中的全部members (内容)?[求助]用ssh tunnel,一连vnc viewer 就不反应了
python code performance --- normal or too slow? (转载)A question about two linux commands
一个头痛的regular expression问题有vim script 高手吗?
vim: how to copy/yank the regular expression matched stringhelp about regex (转载)
regex qstrange behavior about chmod 777 -R
ubuntu 9.04下要装啥才能解决某些在线视频不能观看的问题?不用安装的trash bin?
有regex / apache rewrite rule 高手吗如何搜索installed package 如果不知道全名的话
一行命令找出html中所有img src?PHP编译完后Extension到哪里去了?
相关话题的讨论汇总
话题: matches话题: regular话题: expression话题: enumerate话题: aaaaa
进入Linux版参与讨论
1 (共1页)
G*********a
发帖数: 1080
1
【 以下文字转载自 Java 讨论区 】
发信人: GreenPapaya (为什么我是我 [请勿置顶]), 信区: Java
标 题: Regular Expression question: how to enumerate all matches?
发信站: BBS 未名空间站 (Tue May 26 07:46:13 2009)
I want to obtain all the possible matches of "a" from aaaaa, that should be:
a
aa
aaa
aaaa
aaaaa
but 'a+' does not do the the job, it only returns the longest match "aaaaa".
how can i get all the possible matches enumerated? Thanks!
m******t
发帖数: 2416
2

be:
".
I don't think you can come up with one regex to get them all.
You could construct "a{i}" dynamically where i steps from 1 to 5. Or take
substrings of "aaaaa" and try matching each of them against "a+"
But what exactly are you trying to achieve?

【在 G*********a 的大作中提到】
: 【 以下文字转载自 Java 讨论区 】
: 发信人: GreenPapaya (为什么我是我 [请勿置顶]), 信区: Java
: 标 题: Regular Expression question: how to enumerate all matches?
: 发信站: BBS 未名空间站 (Tue May 26 07:46:13 2009)
: I want to obtain all the possible matches of "a" from aaaaa, that should be:
: a
: aa
: aaa
: aaaa
: aaaaa

r*******n
发帖数: 3020
3
in vim, you just use the option of g[lobal]
like this.
it will put each matches in a single line,
and then you can move them to the end of file
by this:
be:
".
1 (共1页)
进入Linux版参与讨论
相关主题
PHP编译完后Extension到哪里去了?regex q
D 好像是一个很现实的 C/C++ 替代品ubuntu 9.04下要装啥才能解决某些在线视频不能观看的问题?
How to set a lisp variable in .emacs? / How to set Mac command key as meta key ?有regex / apache rewrite rule 高手吗
大牛介绍一下 GPL v3一行命令找出html中所有img src?
请教一个Python问题, 怎么读出一个data structure中的全部members (内容)?[求助]用ssh tunnel,一连vnc viewer 就不反应了
python code performance --- normal or too slow? (转载)A question about two linux commands
一个头痛的regular expression问题有vim script 高手吗?
vim: how to copy/yank the regular expression matched stringhelp about regex (转载)
相关话题的讨论汇总
话题: matches话题: regular话题: expression话题: enumerate话题: aaaaa