当前位置: 动力学知识库 > 问答 > 编程问答 >

Find Numbers Equal to or Greater than 1 using regex

问题描述:

I'm not a developer or scripter. I can't contribute much to this forum but I do use it to get guidance for my staff of developers. That's my disclaimer because the last time I was on this site, someone reamed me out for asking questions and not contributing. For this, I do apologize.

If anyone is willing to assist, or at least give me a kick-start, how would I find the version of a file if the version has #.#.###; i.e., 6.1.3890?

So, my goal is to find a number that is equal to or greater than 1 and equal to or greater than 389. I am only concerned with the digits after the first l'.' and the second '.'

Thanks to any and all.

网友答案:

A regex for a number greater than 389:

(39[0-9]|[4-9][0-9][0-9]|[1-9][0-9][0-9][0-9]+)

A regex for a number greater than 1:

([2-9]|[1-9][0-9]+)

A combined regex for version above 6.1.389:

(6\.1\.(39[0-9]|[4-9][0-9][0-9]|[1-9][0-9][0-9][0-9]+)|6\.([2-9]|[1-9][0-9]+)\.[0-9]+|([7-9]|[1-9][0-9]+)\.[0-9]+\.[0-9]+)

Non zero numbers should not start with a 0.

If the version number format is limited to #.#.### or possibly fewer digits for the last part, the regex can be simplified to:

(6\.1\.(39[0-9]|[4-9][0-9][0-9])|6\.[2-9]\.[0-9]+|[7-9]\.[0-9]\.[0-9]+)
分享给朋友:
您可能感兴趣的文章:
随机阅读: