segunda-feira, 25 de novembro de 2024

How to show errors in JSON string, RegEx string in Microsoft Visual Studio

Example:

//lang=regex
var pattern = "(Mr\\.???\\? |Mrs\\.? |Miss |Ms\\.? )";

//lang=json,strict
var json = """
            {

                "name": "TONY",
                "age": 36,
                "books":
                    [
                        {"Title": "ABC"},
                        {"Title": "DEF"}
                    ]
            }
           """;


Sources:

JSON002: Probable JSON string detected - Visual Studio (Windows) | Microsoft Learn

Hassan Habib on X: "Did you know that Microsoft Visual Studio will show you errors in your JSON string if you just put a comment //lang=json? #json #csharp #dotnet https://t.co/Ir7HR9Cbw1" / X

See also:

.NET regular expressions
https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expressions

ReGex Generator
https://regex-generator.olafneumann.org/

regex101: build, test, and debug regex
https://regex101.com/


Nenhum comentário :