Giter Site home page Giter Site logo

flux's People

Contributors

krolow avatar pborreli avatar peter279k avatar roxburghm avatar selvinortiz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flux's Issues

Zero sized ranges don't create valid patterns

Hi,

Thanks for lib, great. Slight issue

->letters(0,1)

creates a pattern

[a-zA-Z]+

rather than

[a-zA-Z]{0,1}

Fix is to compare to null rather than if ($min) which fails if ZERO provided.

Same in all other functions where min and max allowed.

Matt

public function letters($min = null, $max = null)
{

    if (!is_null($min) && !is_null($max))
    {
        return $this->raw(sprintf('([a-zA-Z]{%d,%d})', $min, $max));
    }
    elseif (!is_null($min) && is_null($max))
    {
        return $this->raw(sprintf('([a-zA-Z]{%d})', $min));
    }
    else
    {
        return $this->raw('([a-zA-Z]+)');
    }
}

Negative look behind or not()

the implementation of:

$flux->not('something');

would be of great use to myself

(?!something)

An implementation of:

public function not($string)
{
    return $this->raw(sprintf('(?!%s)', $string));
}

US Date example error?

I don't know if my port has done something wrong here, but the example of US Date doesn't match my output.

// Pattern /^(\()(\d{3})(\))( )?(\d{3})([ \-])(\d{4})$/
echo $flux->match( $date ) ? 'matched' : 'unmatched'; // matched
echo $flux->replace( '$3/$5/$7', $date ); // 612.424.0013

Yet mine outputs:

//Pattern (\w+)(, )([a-zA-Z]{3})( )(\d{1,2})(, )(\d{4})
// matched
// Jul/22/2013

And here is the code:

var USDate = new Flux();

var testDate = 'Monday, Jul 22, 2013';
USDate.startOfLine().word().then(', ').letters(3).then(' ').digits(1, 2).then(', ').digits(4).endOfLine();
console.log(USDate.pattern.join(''));
console.log(USDate.match(testDate) ? "matched" : "unmatched");
console.log(USDate.replace('$3/$5/$7', testDate));

Anything wrong there?

I haven't tested your code as I don't have PHP setup here.

Consider droppping php-5.x supports

Since PHP 7.1 version is released and it's current PHP version.

I think this should be considered.

Once this issue is accepted, I would be happy to this :).

Seed?

What does the seed do? It's default is false but there is no way of overwriting it. It's not changed anywhere, so is it needed?

Node.js port

@selvinortiz, I've written a Node.js port of flux which you can install from the NPM registry here. Function names are the same, it's almost a straight port, only a few changes for using new RegExp, the tests pass though.

I'll try and keep the port up to date with this repository and update the README later.

Maybe letters or digits

Is there currently functionality for this type of regular expression:

([A-Z]+)? 

Something like:

$flux->maybe($flux->letters());

or

$flux->maybeLetters();

Any help in this regard would be greatly appreciated

Common Patterns

It feels like based on the fluent interface we're building it would be a good idea to implement common patterns to make the API more fluent.

Maybe methods such as:

  • ssn()
  • phrase()
  • password()
  • username()
  • creditCard()

Thoughts?

removeSegment?

Since you can getSegment, would it be worth being able to removeSegment? It'd only be used really when running tests or maybe changing your regex based on a later condition.

digits 0 or more

I would like to find 0 or more digits, like so:

$flux->digits(0, 10);

however, the digits method will always fall to the else, as 0 is false and the condition states $min && $max see below:

if ($min && $max)
{
    return $this->raw(sprintf('(\\d{%d,%d})', $min, $max));
}

I may be misunderstanding how to achieve the 0 or more with the Flux library. However

if (! is_null($min) && ! is_null($max))

Would resolve the issue for my use case. What would you thoughts be on this?

Word Boundaries

There should be a method for wrapping words in \bword\b boundaries boundary and perhaps a beginBoundary and endBoundary method too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.