本文介绍了JSON数字正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为JSON中的数字字符串编写正则表达式.我对编写正则表达式还不陌生,我在此处找到了一个用于JSON数字的机器图,但是我不确定如何攻击它.

I'm trying to write a regular expression for strings that are numbers in JSON. I'm still new to writing Regular expressions, I found a diagram of a machine for JSON numbers here , but I'm not sure how to attack it.

以下是正则表达式应找到的一些字符串. "22","55.75466","-44.565""55e-2""69234.2423432 E78"感谢您的帮助!

Here are some strings that should be found by the regex. "22","55.75466","-44.565""55e-2""69234.2423432 E78"Any help is appreciated!

推荐答案

作为参考,下面是 http://www.json.org/fatfree.html :

与此匹配的正则表达式为:

The regex that should match this is:

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

这篇关于JSON数字正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 11:04