Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matching syntax #34

Open
pashute opened this issue May 14, 2015 · 0 comments
Open

Matching syntax #34

pashute opened this issue May 14, 2015 · 0 comments

Comments

@pashute
Copy link

pashute commented May 14, 2015

Sorry for wasting your time and mine. I didn't read the code, and thought you don't have this.
Also misunderstood how this works. - I thought it was an alternative to regex, now I understand that its a regex builder. (Is the reverse being considered?)

Looked at the tests and saw the capture syntax which is much better than mine (BeginCapture, EndCapture).


My original comment:

Matching syntax for getting lists of text

  • Saved groups: .MatchBy

  • Grouping: Non saving groups: .MatchFor .

  • Dependency: And. Or

  • .AllThat .FirstThat .LastThat .AnyThat

  • .Is .IsNot .IsLike (wildcard syntax) .HasFormat (String.Format() syntax)

  • .HasDate( DateFormat DateSeperator ) HasTime, HasDateAndTime

  • .Until (inclusive), Before (non inclusive until) , After (starts after the found text)

  • .HasUnicode .HasAscii .Has (calls delegate with params)

    '''C#
    [TestMethod]
    public void TestingIfWeHaveAValidURL()
    {
    // Create an example of how to find the params in a RESTful url
    var verbEx = new VerbalExpressions()
    .MatchFor( name:"param code", () => {
    .AnyThat( afterOccurence: 1) // all matches after 1st param found by next match
    // this is the way to get parenthesis around a group of rules
    .MatchFor( name: "param name", () => {
    .After("?").Or.After(";")
    MatchBy( name: "param name", () => {
    .Anything.Before("=")
    });
    });
    .And.MatchFor( name: "param val", ()=>{
    .After( matchFor: "param name")
    //.Maybe(Environment.Quotemark)
    .MatchBy(name: "param val", ()=>{
    .Until.
    //Maybe(Environment.Quotemark)
    .Then(";").Or.EndOfLine;
    });
    });

        // Create an example URL
        var testMe = "https://www.google.com?param1=val1;&param2=val2";
        var matches = verbEx.Match( testMe );
        Assert.IsGreaterThan( matches.Count, 0, "The URL has no parameters");
    
        Console.WriteLine("We have a correct URL ");
    }
    

    '''

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant