由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Unix版 - a question about regular expression
相关主题
read file help!how to count string times using perl
regex: what does [^ ] mean?[转载] perl: regex
regular expression question如何删除从行首到某个特定字符串之间的内容?
Regular expression的问题how to delete a file with NULL name in unix? (转载)
ASK AGAIN!!!Re: How to open/edit a huge text fileRe: 如何限制用户锁屏?
XEmacs C++-font-lock custumizing questionRe: help! how to do this? (no one knows?)
regexp helpwhat is the short cut for repeat search in emacs?
help on emacs / replacehow to copy/paste texts between 2 files in vi?
相关话题的讨论汇总
话题: dir话题: question话题: vi话题: expression话题: regular
进入Unix版参与讨论
1 (共1页)
w****c
发帖数: 10
1
one question about regular expression:
assuming we have statement as following:
%var1%/dir:%var2%/dir:%var3%/dir
in vi, it is expected that using s/%\(.*\)%/$\1/g the above
could be converted to "$var1/dir:$var2/dir:$var3/dir".but
I found that it wound up with "$var1%/dir:%var2%/dir:%var3/dir",
that is, vi searchs for largest matchup. How could I get the
fewest match up?
it is very interesting question. hope unix guru could help me.
Acton
x*****i
发帖数: 253
2
does vi support non-greedy regex..? in vim.. u
can do s/%\(.\{-}\)%/$\1/g...
none of those regex engine
can reach the level Perl(c#) does..:)

【在 w****c 的大作中提到】
: one question about regular expression:
: assuming we have statement as following:
: %var1%/dir:%var2%/dir:%var3%/dir
: in vi, it is expected that using s/%\(.*\)%/$\1/g the above
: could be converted to "$var1/dir:$var2/dir:$var3/dir".but
: I found that it wound up with "$var1%/dir:%var2%/dir:%var3/dir",
: that is, vi searchs for largest matchup. How could I get the
: fewest match up?
: it is very interesting question. hope unix guru could help me.
: Acton

w****c
发帖数: 10
3
sorry, seems not work well.

【在 x*****i 的大作中提到】
: does vi support non-greedy regex..? in vim.. u
: can do s/%\(.\{-}\)%/$\1/g...
: none of those regex engine
: can reach the level Perl(c#) does..:)

w*****n
发帖数: 94
4
if vi does not support non-greedy regexp, try to use
[\w]* or [a-zA-Z0-9]* or [^%]* instead of .*

【在 w****c 的大作中提到】
: sorry, seems not work well.
x*****i
发帖数: 253
5
read carefully.. vim(vi iMprovement) is not vi..

【在 w****c 的大作中提到】
: sorry, seems not work well.
1 (共1页)
进入Unix版参与讨论
相关主题
how to copy/paste texts between 2 files in vi?ASK AGAIN!!!Re: How to open/edit a huge text file
help: how to install the gnu make .XEmacs C++-font-lock custumizing question
does AIX support locate command?regexp help
how to let grep searchhelp on emacs / replace
read file help!how to count string times using perl
regex: what does [^ ] mean?[转载] perl: regex
regular expression question如何删除从行首到某个特定字符串之间的内容?
Regular expression的问题how to delete a file with NULL name in unix? (转载)
相关话题的讨论汇总
话题: dir话题: question话题: vi话题: expression话题: regular