我很新ruby,我可以ruby scripts轻松地在命令行上运行,但我想将我的脚本输出到浏览器,而不仅仅是使用命令行.
非常感谢您的帮助,谢谢.
我有类似的字符串 var=test;path=test.html
我想转换这些类型的字符串,如下面打印的数组:
Array
{
var => test
path => test.html,
}
Run Code Online (Sandbox Code Playgroud)
我试图PHP's explode function用于此任务,但这是将字符串转换为关联数组,然后我决定将该关联数组转换为上面显示的那个.
但是我自己的代码并不是我想要的,因为它包含2次PHP's explode function和一些foreach loops代码,因此我自己的代码不会代表这样一个简单任务的性能部门.
非常感谢您的帮助,谢谢.
我的一些HTML文件包含如下字符串:
{foreach $any_kind_of_charaters}
Any kind of string including "\n\r" and spaces here
{/foreach}
Run Code Online (Sandbox Code Playgroud)
我想申请PHP's preg_match_all他们,并希望返回一个array像下面打印的好
Array
(
[0] => {foreach $any_kind_of_charaters}
Any kind of string including "\n\r" and spaces here
{/foreach}
[1] => any_kind_of_charaters
[2] => Any kind of string including "\n\r" and spaces here
)
Run Code Online (Sandbox Code Playgroud)
这个REGEX:/\{foreach\s+\$(.*)\}\s+(.*)\s+\{\/foreach\}/对我来说还可以,
但是当我在{foreach}{/foreach}标签之间添加新行(\n)时它会失败.
非常感谢您的帮助,谢谢.
使用"S"修改器后的阵列
Array
(
[0] => {foreach $any_kind_of_charaters}
Any kind of string including "\n\r" and spaces here
{/foreach}
[1] => any_kind_of_charaters}
Any kind of …Run Code Online (Sandbox Code Playgroud)