Skip to content

Instantly share code, notes, and snippets.

@100lp
Last active December 14, 2015 04:49

Revisions

  1. 100lp revised this gist Feb 27, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion regexp.rb
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ def alex(string)
    if string[/^\d/]
    1
    elsif string[/123#/]
    555
    2
    else
    if string.scan(/1/).size == 1
    3
  2. 100lp revised this gist Feb 27, 2013. 1 changed file with 5 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions regexp.rb
    Original file line number Diff line number Diff line change
    @@ -6,8 +6,10 @@ def alex(string)
    else
    if string.scan(/1/).size == 1
    3
    else
    elsif string.scan(/1/).size > 1
    4
    else
    0
    end
    end
    end
    @@ -16,4 +18,5 @@ def alex(string)
    puts alex("12345")
    puts alex("a123#451233")
    puts alex("a12345")
    puts alex("a11234511")
    puts alex("a1231451111")
    puts alex("a2345")
  3. 100lp revised this gist Feb 27, 2013. 1 changed file with 5 additions and 7 deletions.
    12 changes: 5 additions & 7 deletions regexp.rb
    Original file line number Diff line number Diff line change
    @@ -1,21 +1,19 @@
    def alex(string)
    if string[/^\d/]
    1
    elsif string[/123#)/]
    elsif string[/123#/]
    555
    else
    if string[/1{1}/]
    if string.scan(/1/).size == 1
    3
    elsif string[/1{2,}/]
    else
    4
    else
    00
    end
    end
    end


    puts alex("12345")
    puts alex("a123#45")
    puts alex("a112345")
    puts alex("a123#451233")
    puts alex("a12345")
    puts alex("a11234511")
  4. 100lp revised this gist Feb 25, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion regexp.rb
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    def alex(string)
    if string[/^\d/]
    1
    elsif string[/(123#)/]
    elsif string[/123#)/]
    555
    else
    if string[/1{1}/]
  5. 100lp revised this gist Feb 25, 2013. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions regexp.rb
    Original file line number Diff line number Diff line change
    @@ -3,17 +3,19 @@ def alex(string)
    1
    elsif string[/(123#)/]
    555
    if string[/1{1}/]
    else
    if string[/1{1}/]
    3
    elsif string[/1{2,}/]
    4
    else
    00
    end
    else
    0
    end
    end


    puts alex("aa123jsh11fskjh24324r3")
    puts alex("12345")
    puts alex("a123#45")
    puts alex("a112345")
    puts alex("a11234511")
  6. 100lp revised this gist Feb 25, 2013. 1 changed file with 11 additions and 9 deletions.
    20 changes: 11 additions & 9 deletions regexp.rb
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,19 @@
    def alex(string)
    if string[/^d/]
    if string[/^\d/]
    1
    elsif string[/(123#)/]
    555
    if string[/1/]
    4
    else
    3
    end
    if string[/1{1}/]
    3
    elsif string[/1{2,}/]
    4
    else
    00
    end
    else
    0
    end
    end


    puts alex("1aa123#jshfskjh24324r3")
    puts alex("aa123jsh11fskjh24324r3")
  7. 100lp revised this gist Feb 25, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions regexp.rb
    Original file line number Diff line number Diff line change
    @@ -5,8 +5,8 @@ def alex(string)
    555
    if string[/1/]
    4
    else
    3
    else
    3
    end
    else
    0
  8. 100lp revised this gist Feb 25, 2013. 1 changed file with 10 additions and 5 deletions.
    15 changes: 10 additions & 5 deletions regexp.rb
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,17 @@
    def alex(string)
    if string[0] == "1"
    if string[/^d/]
    1
    elsif string[/[123]/]
    555
    elsif string[/(123#)/]
    555
    if string[/1/]
    4
    else
    3
    end
    else
    0
    0
    end
    end


    puts alex("111jshfskjh24324r3")
    puts alex("1aa123#jshfskjh24324r3")
  9. 100lp created this gist Feb 25, 2013.
    12 changes: 12 additions & 0 deletions regexp.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    def alex(string)
    if string[0] == "1"
    1
    elsif string[/[123]/]
    555
    else
    0
    end
    end


    puts alex("111jshfskjh24324r3")