由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 这个PERL表达式干啥的?
相关主题
诚心请教Perl:简单的Variable Match in Regular expressionperl 的问题
请教一个变态的regular expression 替换python象C/C++, ruby象java
why int** cannot convert to const int** ?问个关于正则表达式的超弱智问题...
a question about CASTperl能不能一次把一个str中的a替换成x,b替换成y? (转载)
请教Regular Expression,请教一个perl的替换问题。
Perl插入MySQL中双引号的问题求教一个perl问题
怎样才能用perl等东西知道c macro中的数值关于scala的level
python能检查出space是一个还是两个吗?what's wrong with this C++ code?
相关话题的讨论汇总
话题: perl话题: means话题: 表达式话题: sel话题: word
进入Programming版参与讨论
1 (共1页)
y***a
发帖数: 840
1
my $ooo = ($abb =~ m!\b(?:ld\w+p\b|m\w+sel\b|aaa|bbb|ccc)\w*!o);
看着不像查找m//
哪位给讲讲
t****t
发帖数: 6806
2
m// can actually use arbitrary delimiter, as long as they match. in this
case, he apparently used "!" as delimiter.

【在 y***a 的大作中提到】
: my $ooo = ($abb =~ m!\b(?:ld\w+p\b|m\w+sel\b|aaa|bbb|ccc)\w*!o);
: 看着不像查找m//
: 哪位给讲讲

t*****n
发帖数: 4908
3
天书一般的程序,特别是没注释的。。。

【在 y***a 的大作中提到】
: my $ooo = ($abb =~ m!\b(?:ld\w+p\b|m\w+sel\b|aaa|bbb|ccc)\w*!o);
: 看着不像查找m//
: 哪位给讲讲

l*********s
发帖数: 5409
4
if this needs comment, you pretty much lose the advantage of using perl
because you are going to comment almost every line
:-).

【在 t*****n 的大作中提到】
: 天书一般的程序,特别是没注释的。。。
t****t
发帖数: 6806
5
for perl RE, using /x modifier for complex RE is a good idea. You don't have
to use comments, just try to "group" with space.

【在 l*********s 的大作中提到】
: if this needs comment, you pretty much lose the advantage of using perl
: because you are going to comment almost every line
: :-).

l*********s
发帖数: 5409
6
Part of the reasons for perl being hard to learn is there are tons of
shortcuts. No doubt it is a language designed for the experienced.


have

【在 t****t 的大作中提到】
: for perl RE, using /x modifier for complex RE is a good idea. You don't have
: to use comments, just try to "group" with space.

t****t
发帖数: 6806
7
本来就是自用的语言, 没指望拿perl写个大程序是不是? 可读性是差, 但是本来就不是
用来读的.

【在 l*********s 的大作中提到】
: Part of the reasons for perl being hard to learn is there are tons of
: shortcuts. No doubt it is a language designed for the experienced.
:
:
: have

l*******G
发帖数: 1191
8

m! !o means to search the thing in between ! ! and compile once
[1] (?: ) Means to group but not catch the things found into
$1,$2,$3 etc internal expressions
[2] ld\w+p\b Means to match ld*p ended by a word boundary , where
* is any one or more char of a-z,A-Z,0-9 or _
[3] m\w+sel\b Means to match m*sel followed by a word boundary where
* is same as above,
\b means word boundary
[4] aaa, bbb, ccc are plain string of aaa, bbb, ccc
the whole thing tries to match contents in $abb with one of above [2]to [4]
followed by zero, one or more of any other word char of a-zA-Z0-9_
and then compile once, and then give the results to $ooo
The compile once modifier o means only evaluate the pattern once, to save
time.
http://perl.plover.com/Regex/article.html
http://www.perlmonks.org/?node_id=905041

【在 y***a 的大作中提到】
: my $ooo = ($abb =~ m!\b(?:ld\w+p\b|m\w+sel\b|aaa|bbb|ccc)\w*!o);
: 看着不像查找m//
: 哪位给讲讲

1 (共1页)
进入Programming版参与讨论
相关主题
what's wrong with this C++ code?请教Regular Expression,
Do the two statements cost the same amount of time?Perl插入MySQL中双引号的问题
java 里可以插入linux command吗? (转载)怎样才能用perl等东西知道c macro中的数值
typedefpython能检查出space是一个还是两个吗?
诚心请教Perl:简单的Variable Match in Regular expressionperl 的问题
请教一个变态的regular expression 替换python象C/C++, ruby象java
why int** cannot convert to const int** ?问个关于正则表达式的超弱智问题...
a question about CASTperl能不能一次把一个str中的a替换成x,b替换成y? (转载)
相关话题的讨论汇总
话题: perl话题: means话题: 表达式话题: sel话题: word