我必须从文本中解析一堆统计数据,它们都被格式化为数字。
例如这段话:
A total of 81.8 percent of New York City students in grades 3 to 8 are meeting or exceeding grade-level math standards, compared to 88.9 percent of students in the rest of the State.
我只想匹配 81 和 88 数字,而不是后面的“.8”和“.9”。
我该怎么做?我听说过反向引用或前瞻之类的术语。这些有帮助吗?
我正在使用 C#。
编辑: 要求我在上面的例子中得到“3”和“8”。这只是一个简单的示例,但我几乎需要所有数字。
请您参考如下方法:
/[^.](\d+)[^.]/
如下所述,只需使用 MatchObj.Groups(1) 即可获取数字。
