-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmore.rb
74 lines (52 loc) · 1.25 KB
/
more.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
def something
longstring = "this is a long string."
longstring['long'] = 'long long long long long'
puts (longstring)
end
def hashtest
person = {"name" => "XiaoYao Li",
"age" => 19}
#puts(person)
print "Name:", person['name']
print "Age:", person['age']
group = {'leader'=>person,
'follower'=>{'name'=>'YueRu Lin',
'age'=>18}
}
for index in 0...group.keys.length
print group[group.keys[index]]
end
group.each{|eachk, eachv|
puts(eachk, eachv)
}
end
def stringtest
string1 = "to be complete"
string1 << "d"
puts (string1)
stringlist = ['a','b','city','delta']
stringlist.each{|eachs| print eachs.capitalize << "\""}
end
def regexptest
string = "I will drill a well from walla walla washington."
regex = Regexp.new(/w.ll/)
matched = regex.match(string)
if matched
puts matched[0]
puts matched[1]
else
puts "NO MATCH"
end
puts "remained", matched.post_match
while matched != nil
puts matched[0]
string1 = matched.post_match
matched = regex.match(string1)
end
end
begin
#something()
#hashtest()
#stringtest()
regexptest()
end