简体   繁体   English

正则表达式查找特定模式

[英]Regex to find a specific pattern

{
    "rows": 10,
    "os": "0",
    "page": "1",
    "total": "1",
    "peoples": {
        "123": {
            "url": "http://google.com",
            "id": "123",
            "fname": "Rob",
            "lname": "Tom",
            "full_name_ac": "Rob Tom"
        }
    }
}

I am trying to write a regex to get a full name in c# something like /("full_name_ac": ")\\w +, but not able to write.Please help me to write the regex that will always find the value under double quotes for full_name_ac我正在尝试编写一个正则表达式来在 c# 中获取全名,例如/("full_name_ac": ")\\w +,但无法写入。请帮助我编写始终在双引号下找到值的正则表达式对于 full_name_ac

Your RegEx to extract a full_name_ac value out of this string should look like您从该字符串中提取full_name_ac值的 RegEx 应如下所示

(?<="full_name_ac": ")[\w\ ]+(?=\")

Explaination:说明:

(?<="full_name_ac": ") - starts with "full_name_ac": " but it's not a part of the value (?<="full_name_ac": ") - 以"full_name_ac": "开头,但它不是值的一部分

[\\w\\ ]+ the name including space with at lease one character [\\w\\ ]+包含至少一个字符的空格的名称

(?=\\") and the string has to end with a " which isn't a part of the value (?=\\")和所述串具有与结束"这不是值的一部分

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM