Retired

Make ruby 'match' output similar to js 'match' return (retired)

Description
Loading description...
Regular Expressions
  • Please sign in or sign up to leave a comment.
  • cliffstamp Avatar

    Ruby :

    • similar to issues noted in the above, there are lots of non-scan solutions that are avoiding the intended solution which isn't enforced by the test suite

    This Kata likely won't get approved unless :

    • the description is clarified to allow any function to make the desired result happen (in which cases it is ~8 kyu)

    • if that happens, the kata is likely going to get flagged because then it becomes a very basic grouping Kata

    • a lot of restrictions are in place to force someone to either just use match or put a lot of work to get around blocks

    Nice work on the test suite, aside from that anyway.

  • Unihedron Avatar

    This comment has been hidden.

  • Firefly2002 Avatar

    Fun little kata. Might it make sense to disable other things like eval, split, and maybe even match itself, and add test cases that include other characters? I might definitely have misunderstood your intent.. I was thinking along the lines of a kata that has to do something a little more step-by-step than in one line. If so, ignore me :)

    • lbvf50mobile Avatar

      Hi @Firefly2002, thank you for your feedback. It's very nice when my work is intresting and dose not waste. This kata is a challange for users of local ruby chat and investigation of Ruby regex. History of creation this kata: I got this js regex /([?!])\1*/ from solution of Exclamation marks series #18 kata, translating to Ruby found different in behaviour in Ruby/JS regex ( https://goo.gl/4vpKb6 ) . This leads to argue in the local chat, so I created kata to find ways to use Ruby.match work as like JS.match with particular regex.

    • Firefly2002 Avatar

      Oh okay :)

  • Voile Avatar

    So if your intent is to disable the use of scan, you need to actually disable it (by un-defining it in preloaded.

    Also you should make sure we're not using other regexes.

    • lbvf50mobile Avatar

      Ok. got it. will be wokring with it. Thank you

    • lbvf50mobile Avatar

      I thought it possible to solve this problem using s.match(some_other_regex).some_other_method_may_be but I do not think in this situation need to prevent other regex.

      But it's interesting what tis preloaded and how to wield with them. At curren moment I tured off scan by rewriting scan method.

    • lbvf50mobile Avatar

      And also it's intersting how it's possible to prevent othre regex techically. Thank you

    • Voile Avatar

      Pass in the regex as a parameter?

    • lbvf50mobile Avatar

      Pass in the regex as a parameter?

      I'm not sure what is a question? You mean rewrite method and check do regex equal to some othre ethalon?

      Ethalon = /aaa/
      def String.match regex
        return fails_test if regex != Ethalon
        super
      end