我выражение
从互联网上获取任何用于在字符串中搜索匹配项的内容,并执行以下操作:/(^(выражение))|(выражение)|((выражение)$)|(^(выражение)$)/
,但如果它位于字符串末尾,则它不会捕获字符串中的地址,并且一切都在服务器端表达式模拟器中运行。如何写出正确的表达方式?我看到有些人$
使用\z
严格的行尾来代替,但我仍然不明白如何在这个插件中正确捕获开头或结尾。
我使用 MYSYS2(MINGW64) 安装了 Ruby,并使用gem install haml安装了Haml Gem 。 在项目文件夹中,我创建了捆绑Gemfile 命令,编写“gem haml”并通过安装haml 的捆绑安装依赖项来完成所有操作
命令haml index.haml index.html后 输出有错误,我该怎么办?
C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/haml-6.2.3/lib/haml/cli.rb:114:in `method_missing': undefined method `index.haml' for #<Haml::CLI:0x00000164de897eb8 @_invocations={Haml::CLI=>["index.haml"]}, @_initializer=[["index.html"], [], {:shell=>#<Thor::Shell::Basic:0x00000164de221bd8 @base=#<Haml::CLI:0x00000164de897eb8 ...>, @mute=false, @padding=0, @always_force=false>, :current_command=>#<struct Thor::DynamicCommand name="index.haml", description="A dynamically-generated command", long_description="index.haml", wrap_long_description=nil, usage="index.haml", options={}, options_relation={}, ancestor_name=nil>}], @options={"escape_html"=>true, "escape_attrs"=>true}, @args=["index.html"], @shell=#<Thor::Shell::Basic:0x00000164de221bd8 @base=#<Haml::CLI:0x00000164de897eb8 ...>, @mute=false, @padding=0, @always_force=false>> (NoMethodError)
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/thor-1.3.0/lib/thor/command.rb:30:in `run'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/thor-1.3.0/lib/thor/command.rb:144:in `run'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/thor-1.3.0/lib/thor/base.rb:584:in `start'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/haml-6.2.3/exe/haml:6:in `<top (required)>'
from C:/Ruby32-x64/bin/haml:32:in `load'
from C:/Ruby32-x64/bin/haml:32:in `<main>'
刚刚通过npx react-native init AwesomeTSProject --template react-native-template-typescript
. Expo 不适合我,因为据我所知,这个框架只为 Android 和 iOS 构建,我打算在所有支持的平台上运行该应用程序。
一般来说,我尽量不使用项目生成器,原因有两个:
- 很多不必要的
- 建议的文件结构通常不适合我。
但是,我还没有 100% 手动部署 React Native 项目的方法,因此我必须清理和重新组织建议的文件结构。
首先引起您注意的是 Ruby 文件(.ruby-version、 Gemfile、Gemfile.lock)的存在。从逻辑的角度来看,尚不清楚这些文件在 React Native 项目中的作用——他们是否建议我用 Ruby 编写服务器部分?
那么,第二个问题是是否可以安全地删除所有这些文件。
学习 Tadayoshi Funaba 日历程序 (cal.rb)
首先,为日历创建一个星期指定数组,以根据当前日期工作:
require 'date'
fi = Date.new(1, 1, 1)
ve = (fi..fi + 6).collect{|cu|
%w(Вс Пн Вт Ср Чт Пт Сб)[cu.wday]
}
=> ["Сб", "Вс", "Пн", "Вт", "Ср", "Чт", "Пт"]
这里的数组对于任何初学者来说都像往常一样。然后将月份中的天数添加到此数组中,以获得将其转换为给定月份的日历输出所需的存根数组:
ve += (fi..fi + 41).collect{|cu|
if cu.mon == 1 then cu.send(:mday) end.to_s
}
=>
["Сб",
"Вс",
"Пн",
"Вт",
"Ср",
"Чт",
"Пт",
"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",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
""]
然后我们得到一堆换行符,就像它是一个多字符串,而不是一个数组......它们来自哪里,它是如何工作的?
此外,选择子阵列时将保留这些翻译:
(0..ve.size / 7 - 1).collect{|i| ve[i * 7, 7]}
=>
[["Сб", "Вс", "Пн", "Вт", "Ср", "Чт", "Пт"],
[" 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", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " "]]
我完全不明白数组会发生什么,也许是没有详细解释的日期模块方法的一些影响?
我正在关注 Ruby 教程。我的任务是了解如何将对象保存到 yaml 字符串并使用标准 YAML 模块恢复它们,但我遇到了一个失败的教程代码:
require 'yaml'
class Person
attr_accessor :first_name, :last_name, :patronymic, :password
def initialize(first_name:, last_name:, patronymic:, password:)
@first_name = first_name
@last_name = last_name
@patronymic = patronymic
@password = password
end
end
person = Person.new(
first_name: 'Иван',
last_name: 'Петрович',
patronymic: 'Сидоров',
password: 'qwerty'
)
yaml_str = YAML.dump(person) # интересует именно эта часть кода,
recovered = YAML.load(yaml_str) # чтобы восстановить объект из той же переменной
p recovered.first_name # "Иван"
p recovered.last_name # "Петрович"
p recovered.patronymic # "Сидоров"
p recovered.password # "qwerty"
该程序输出以下内容:
C:/Ruby31-x64/lib/ruby/3.1.0/psych/class_loader.rb:99:in `find': Tried to load unspecified class: Person (Psych::DisallowedClass)
from C:/Ruby31-x64/lib/ruby/3.1.0/psych/class_loader.rb:28:in `load'
from C:/Ruby31-x64/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:424:in `resolve_class'
from C:/Ruby31-x64/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:213:in `visit_Psych_Nodes_Mapping'
from C:/Ruby31-x64/lib/ruby/3.1.0/psych/visitors/visitor.rb:30:in `visit'
from C:/Ruby31-x64/lib/ruby/3.1.0/psych/visitors/visitor.rb:6:in `accept'
from C:/Ruby31-x64/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:35:in `accept'
from C:/Ruby31-x64/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:318:in `visit_Psych_Nodes_Document'
from C:/Ruby31-x64/lib/ruby/3.1.0/psych/visitors/visitor.rb:30:in `visit'
from C:/Ruby31-x64/lib/ruby/3.1.0/psych/visitors/visitor.rb:6:in `accept'
from C:/Ruby31-x64/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:35:in `accept'
from C:/Ruby31-x64/lib/ruby/3.1.0/psych.rb:335:in `safe_load'
from C:/Ruby31-x64/lib/ruby/3.1.0/psych.rb:370:in `load'
from C:/Users/armoy/OneDrive/Documents/selflearning_book/FTP/modules/yaml_load.rb:21:in `<main>'
宝石 psych-4.0.3。YAML 模块的 load 方法的 ri 实用程序似乎没有写任何有趣的东西。