Skip to content

Instantly share code, notes, and snippets.

@100lp
Last active December 14, 2015 04:49
Show Gist options
  • Save 100lp/5030853 to your computer and use it in GitHub Desktop.
Save 100lp/5030853 to your computer and use it in GitHub Desktop.
# On 2/20/13, at 01:30, Alexey Gaziev wrote: > посмотрите информацию по методу match у String <br /> [*On 2/20/13, at 01:30, Alexey Gaziev wrote:*] > и по методу =~ [19:14:26] Alexey Gaziev: посмотрите и сделайте мне следующую тему - [19:14:32] Alexey Gaziev: 1. В метод приходит строка [19:15:00] Alexey Gaziev: 2. Если строка содержит в начале ч…
def alex(string)
if string[/^\d/]
1
elsif string[/(123#)/]
555
else
if string[/1{1}/]
3
elsif string[/1{2,}/]
4
else
00
end
end
end
puts alex("12345")
puts alex("a123#45")
puts alex("a112345")
puts alex("a11234511")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment