Project1
标题: 刚刚写了个小脚本,这里测试一下 [打印本页]
作者: 寒冷魔王 时间: 2014-8-14 21:10
标题: 刚刚写了个小脚本,这里测试一下
def search(include,note)
len = include.size
for nth in 0..note.size
return nth if note[nth, len] == include
end
return nil
end
def input(note,include)
len = include.size+1
nth = search(include,note) + len
nth2 = search("\r\n",note)
return note[nth,nth2-nth]
end
p input("哈哈喵呜喵5:233\r\n呃呃呃","喵呜喵5")
def search(include,note)
len = include.size
for nth in 0..note.size
return nth if note[nth, len] == include
end
return nil
end
def input(note,include)
len = include.size+1
nth = search(include,note) + len
nth2 = search("\r\n",note)
return note[nth,nth2-nth]
end
p input("哈哈喵呜喵5:233\r\n呃呃呃","喵呜喵5")
知道输出什么吗?@喵呜喵5
作者: taroxd 时间: 2014-8-14 21:33
本帖最后由 taroxd 于 2014-8-14 21:37 编辑
p /喵呜喵5.(.*)\r\n/.match("哈哈喵呜喵5:233\r\n呃呃呃")[1]
p /喵呜喵5.(.*)\r\n/.match("哈哈喵呜喵5:233\r\n呃呃呃")[1]
知道输出什么吗?@寒冷魔王
作者: 寒冷魔王 时间: 2014-8-14 22:22
taroxd 发表于 2014-8-14 21:33 
p /喵呜喵5.(.*)\r\n/.match("哈哈喵呜喵5:233\r\n呃呃呃")[1][/pre]
知道输出什么吗?@寒冷魔王 ...
233
——可怜的@喵呜喵5
作者: 寒冷魔王 时间: 2014-8-14 22:23
本帖最后由 寒冷魔王 于 2014-8-14 22:31 编辑
- #--------------------------------------------------------------------------
- # ● 输出数据
- #--------------------------------------------------------------------------
- def input(note,include)
- len = include.size+1
- n = search(note,include)
- if n == nil then n = 0 end
- nth = n + len
- nth2 = search(note,"\r\n")
- if nth2 != nil
- return note[nth,nth2-nth]
- else
- return note[nth,note.size-nth]
- end
- end
复制代码 @taroxd @余烬之中 更新了一下
——这样input("","喵呜喵5")就不会出错了~{:2_280:}
作者: 喵呜喵5 时间: 2014-8-14 22:35
|д` )
为什么窝老是躺枪……
作者: 克莉丝 时间: 2014-8-14 22:38
你是想让喵呜喵5还是我还是让td和余烬之中笑一个
作者: taroxd 时间: 2014-8-15 06:40
寒冷魔王 发表于 2014-8-14 22:23 
@taroxd @余烬之中 更新了一下
——这样input("","喵呜喵5")就不会出错了~ ...
p /喵呜喵5.(.*)\r\n/ =~ ("哈哈喵呜喵5:233\r\n呃呃呃") ? $1 : nil
这样 p /喵呜喵5.(.*)\r\n/ =~ ("") ? $1 : nil 就不会出错了
作者: 寒冷魔王 时间: 2014-8-15 11:23
本帖最后由 寒冷魔王 于 2014-8-15 11:25 编辑
def 喵呜喵5(开头文字)
return 开头文字 + "的喵呜喵5"
end
def 吐槽(内容)
p 内容
end
吐槽 喵呜喵5("可怜")
def 喵呜喵5(开头文字)
return 开头文字 + "的喵呜喵5"
end
def 吐槽(内容)
p 内容
end
吐槽 喵呜喵5("可怜")
@taroxd @余烬之中 前排围观
@喵呜喵5 你是嘉宾
作者: taroxd 时间: 2014-8-15 11:38
寒冷魔王 发表于 2014-8-15 11:23 
def 喵呜喵5(开头文字)
return 开头文字 + "的喵呜喵5"
end
class << self
alias 吐槽 puts
def method_missing(*args)
args.join(",")
end
end
吐槽 喵呜喵5这么可怜 你们就放过他吧 好吗?
class << self
alias 吐槽 puts
def method_missing(*args)
args.join(",")
end
end
吐槽 喵呜喵5这么可怜 你们就放过他吧 好吗?
作者: 余烬之中 时间: 2014-8-15 11:43
我必须回帖了 楼上的帖子有严重错误
@楼上
class << self
alias 吐槽 puts
def method_missing(*args)
args.join(",")
end
end
吐槽 喵呜喵5这么可怜 你们就放过她吧 好吗?
class << self
alias 吐槽 puts
def method_missing(*args)
args.join(",")
end
end
吐槽 喵呜喵5这么可怜 你们就放过她吧 好吗?
作者: 寒冷魔王 时间: 2014-8-15 11:45
本帖最后由 寒冷魔王 于 2014-8-15 11:48 编辑
- def input2(note,include,ins)
- len = include.size
- n = search(note,include)
- if n == nil then n = 0 end
- nth = n + len
- nth2 = search(note,ins)
- if nth2 != nil
- return note[nth,nth2-nth]
- else
- return note[nth,note.size-nth]
- end
- end
-
- def 喵呜喵5(开头文字)
- return 开头文字 + "的喵呜喵5。"
- end
- def 吐槽(内容)
- p 内容
- end
- def 继续吐槽(内容)
- 吐槽 内容+"总是躺枪。"
- end
- def 关于喵呜喵5的疑问(内容)
- if search(内容,"吗") !=nil
- input2(内容,"喵呜喵5","吗") + "。"
- else
- input2(内容,"喵呜喵5","?") + "。"
- end
- end
- 吐槽 喵呜喵5("可怜")
- 继续吐槽("喵呜喵5")
- 吐槽 关于喵呜喵5的疑问("喵呜喵5可怜吗?")
- 吐槽 关于喵呜喵5的疑问("喵呜喵5是坏人吗?")
- 吐槽 关于喵呜喵5的疑问("喵呜喵5真的是坏人?")
复制代码 @taroxd @余烬之中 继续围观
作者: 寒冷魔王 时间: 2014-8-15 12:04
taroxd 发表于 2014-8-15 11:38 
class
之前
之后
作者: 余烬之中 时间: 2014-8-15 12:04
- def input2(note, inc, ins)
- note =~ /#{inc}(.*)#{ins}/i
- $1
- end
- def 喵呜喵5 a
- a.concat "的#{__method__}。"
- end
- alias 吐槽 puts
- def 继续吐槽 c
- 吐槽 c.concat "总是躺枪。"
- end
- def 关于喵呜喵5的疑问(内容)
- "#{input2(内容, "喵呜喵5", 内容.index("吗").nil? ? "?" : "吗")}。"
- end
复制代码
欢迎光临 Project1 (https://rpg.blue/) |
Powered by Discuz! X3.1 |