Topic: 怎样判别一个字符串是否形如 “int,int-int,int"?

  Print this page

1.怎样判别一个字符串是否形如 “int,int-int,int"? Copy to clipboard
Posted by: zsjust
Posted on: 2005-11-30 07:00

怎样判别一个字符串是否形如 “int,int-int,int"?
又如何获取这四个int数呢?

谢谢

2.Re:怎样判别一个字符串是否形如 “int,int-int,int"? [Re: zsjust] Copy to clipboard
Posted by: ntshenwh
Posted on: 2005-11-30 08:43

我用.Net 中的正则表达式,看看下面的资料,不知道有没有帮助,
http://www.caiblog.com/346/xioxu/1076846.shtml

3.Re:怎样判别一个字符串是否形如 “int,int-int,int"? [Re: zsjust] Copy to clipboard
Posted by: zsjust
Posted on: 2005-11-30 12:21

不用.net呢?

4.Re:怎样判别一个字符串是否形如 “int,int-int,int"? [Re: zsjust] Copy to clipboard
Posted by: why
Posted on: 2005-11-30 17:29

zsjust wrote:
不用.net呢?


Java has RegEx as well:
JDK 1.4 or above: java.util.regex
Java tutorial:
http://java.sun.com/docs/books/tutorial/extra/regex/

Java Alamanc:
http://javaalmanac.com/egs/java.util.regex/pkg.html
http://javaalmanac.com/egs/java.util.regex/Group.html

Apache versions: org.apache.regexp
http://jakarta.apache.org/regexp/
http://jakarta.apache.org/regexp/applet.html

or Jakarta-ORO (Perl-compatible syntax): org.apache.oro.text.regex & org.apache.oro.text.perl
http://jakarta.apache.org/oro/index.html
http://jakarta.apache.org/oro/demo.html


You may use a pattern like "(\d+),(\d+)-(\d+),(\d+)"
This JavaWorld article should be useful to you:
http://www.javaworld.com/javaworld/jw-07-2001/jw-0713-regex.html


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923