This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / Help: Unix expert , please coming about regular expression!!
-smpp(流浪ing);
2003-4-10
{589}
(#1133829@0)
-
try 3[0-9]{10}
-guestagain(guest again);
2003-4-10
(#1133850@0)
-
how to verify?I try this before and not get the right result.
LABSMS0:/ins/sms/conf>echo 21234567890|egrep 3[0-9]{10}
LABSMS0:/ins/sms/conf>echo 31234567890|egrep 3[0-9]{10}
LABSMS0:/ins/sms/conf>echo 31234567890|egrep 3[0-9]{10}
LABSMS0:/ins/sms/conf>
thanks
Roger
-smpp(流浪ing);
2003-4-10
{265}
(#1133873@0)
-
/^3\d*/ or simply /^3\d\d\d\d\d\d\d\d\d\d$/
-redmouthbird(你个老胖弟);
2003-4-10
(#1133883@0)
-
doesn't work, can you tell me know how to verify/ins/sms/conf>grep ^3\d\d\d\d\d\d\d\d\d\d$ test
/ins/sms/conf>grep 3[0-9]{10} test
/ins/sms/conf>grep 3* test
31234567890
23124567899
300055555768
ins/sms/conf>grep 3[0-9]{9} test
/ins/sms/conf>grep 3\d\d\d\d\d\d\d\d\d\d test
/ins/sms/conf>
the file name is test
not get the expect result
-smpp(流浪ing);
2003-4-10
{325}
(#1133902@0)
-
should that be grep "3[0-9]{10}" test ?
-guestagain(guest again);
2003-4-10
(#1133915@0)
-
does not get the expect result.BTW:
what do you guy to verify the expression?
some thing I use
ins> echo 'input string'|egrep 'expression'
in command line
or above mathod
thanks
-smpp(流浪ing);
2003-4-10
{162}
(#1134316@0)
-
try: /^3\d{10}/
-eggplant(老茄子);
2003-4-10
(#1134331@0)
-
It works. see what I got on my system(bourne shell)$ echo 31111111111 | egrep "3[0-9]{10}"
31111111111
$ echo 31111111111 | egrep '3[0-9]{10}'
31111111111
$ echo 311dd111111 | egrep '3[0-9]{10}'
$ echo "311 11111" | egrep '3[0-9]{10}'
$ echo "31155511111" | egrep '3[0-9]{10}'
31155511111
$ echo "21155511111" | egrep '3[0-9]{10}'
-pasu(InTheSky);
2003-4-10
{307}
(#1134508@0)
-
which OS do you have, I got Solaris 8.0?actually, my scenario is very simple , match a digital string with this pattern, and if match this range, then pass this string to next. otherwise reject.
the problem is : the vendor of this application did not give the fully document of this , just tell me use the unix expression , it will work.
I will try it again
thanks
-smpp(流浪ing);
2003-4-11
{330}
(#1136153@0)
-
regexp is always the same. It has nothing to do with the OS. In your case, I beleive you need more support from the application vendor.
-pasu(InTheSky);
2003-4-11
(#1136156@0)
-
Although there's something called POSIX regular expression, it varies slightly from program to program. The most popular ones are sed, grep and perl, here's how...grep: takes one line at a time. "grep '3[0-9]\{10\}' <filename>"
sed: takes one line at a time. "sed -n '/3[0-9]\{10\}/p' <filename>"
perl:
open(IN, "<filename>") or die("cannot open <filename>");
whiel(<IN>) {
if($_=~/3\d{10}/) {
print;
}
}
HTH.
-mocha(Kaa the snake);
2003-4-10
{282}
(#1134355@0)
-
Try this one egrep "^3[0-9]{10} | 3[0-9]{10} | 3[0-9]{10}$". 注意,| 前后是space
-demijohn(老三);
2003-4-10
(#1134424@0)
-
space 也算是字符,若要找以3开头的数字,必须考虑3之前有space 或以3开头的行。grep "3[0-9]{10}” 凡是有3dddddddddd 的字符串都会符合,如23dddddddddd 也符合,所以不对。
-demijohn(老三);
2003-4-10
(#1134453@0)
-
space 也算是字符,若要找以3开头的数字,必须考虑3之前有space 或以3开头的行。grep "3[0-9]{10}” 凡是有3dddddddddd 的字符串都会符合,如23dddddddddd 也符合,所以不对。
-demijohn(老三);
2003-4-10
(#1134502@0)