【问题标题】:Dealing with plus and minus signs in regexpr in R在 R 中处理正则表达式中的加号和减号
【发布时间】:2015-05-07 07:45:27
【问题描述】:

我想在从字符串中提取数字数据时包含减号或加号。编号为 8.81e+001。使用以下代码,我可以获得 e,但不能获得 + 和后续数字。

wg_co2 <- all_data[wg_co2 <- grep("Carbon Dioxide",all_data)] [3]
wg_co2 <-regmatches(wg_co2, regexpr("[0-9]{1,9}.[e-e0-9]{1,9}",wg_co2))
wg_co2

感谢收到任何提示!

JT

【问题讨论】:

    标签: regex r string character numeric


    【解决方案1】:
    [0-9]{1,9}.[[e-e0-9]-]{1,9}[+-][0-9]+
    

    这应该会为你做的

    【讨论】:

    • 这就是我一直在寻找的解决方案!谢谢!
    猜你喜欢
    • 2021-12-04
    • 1970-01-01
    • 2022-01-22
    • 2017-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-16
    • 1970-01-01
    相关资源
    最近更新 更多