由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - regex question
相关主题
再请教一个class输出的问题Can someone help me a quick regex?
re一问要不要学习 scripting languages such as Python?
请教一个变态的regular expression 替换from beautiful code
any way to use regex in Fortran?any perl html parser to recommend?
匹配问题 (转载)GCC TR1 实现regex 没?
装完boost之后还要再装REGEX吗?江湖救急
RegEx puzzle[合集] 统一的regex (grep, sed, awk, python,..)
[合集] regular expression for whitespace in pathstring /File IO processing using C
相关话题的讨论汇总
话题: try话题: regex话题: match话题: begin话题: fraction
进入Programming版参与讨论
1 (共1页)
c********e
发帖数: 383
1
trying to do a regex match on non-zero number.
match : 1.5 0.5 0.9 9.0 90
not match : 0 0.0
but could not find an elegant solution. Any suggestion? thx
c**t
发帖数: 2744
2
match all numbers then exclude 0 or 0.0?

【在 c********e 的大作中提到】
: trying to do a regex match on non-zero number.
: match : 1.5 0.5 0.9 9.0 90
: not match : 0 0.0
: but could not find an elegant solution. Any suggestion? thx

c****j
发帖数: 802
3
a stupid way:
"[1-9]\d*\.\d*|[^.][1-9]\d*[^.]|[0]\.\d*[1-9]\d*"
(fraction begin with 1-9|integer begin with 1-9|fraction begin with0)

【在 c********e 的大作中提到】
: trying to do a regex match on non-zero number.
: match : 1.5 0.5 0.9 9.0 90
: not match : 0 0.0
: but could not find an elegant solution. Any suggestion? thx

m******t
发帖数: 2416
4

Try:
(0*[1-9]\d*(\.\d)?\d*)|(0*\.0*[1-9]\d*)

【在 c********e 的大作中提到】
: trying to do a regex match on non-zero number.
: match : 1.5 0.5 0.9 9.0 90
: not match : 0 0.0
: but could not find an elegant solution. Any suggestion? thx

1 (共1页)
进入Programming版参与讨论
相关主题
string /File IO processing using C匹配问题 (转载)
用sscanf读入一段text中的电话号码,formatter怎么写?装完boost之后还要再装REGEX吗?
regular expressionRegEx puzzle
如何提取大批html文件中规则的信息?[合集] regular expression for whitespace in path
再请教一个class输出的问题Can someone help me a quick regex?
re一问要不要学习 scripting languages such as Python?
请教一个变态的regular expression 替换from beautiful code
any way to use regex in Fortran?any perl html parser to recommend?
相关话题的讨论汇总
话题: try话题: regex话题: match话题: begin话题: fraction