首页
\
问答
\
如何在ruby中获取第一个html标记和第二个html标记之间的内容(how to get the content between the first html tag and the second html tag in ruby)
如何在ruby中获取第一个html标记和第二个html标记之间的内容(how to get the content between the first html tag and the second html tag in ruby)
嗨朋友〜
我想获取第一个html标记和第二个html标记之间的内容。
例如<p>Hello <bold>world</bold>!</p>
将返回Hello
我应该在Ruby中做什么?
谢谢〜Hi friend~
I want get the content between the first html tag and the second html tag.
for example<p>Hello <bold>world</bold>!</p>
will returnHello
What should I do in Ruby?
Thank you~
原文:https://stackoverflow.com/questions/4852213
更新时间:2022-12-04 17:12
最满意答案
正则表达式将是:
<[^>]*>([^<]*)
<[^>]*>
- 数学thiw第一个标签“<...>”([^<]*)
- 捕获文本以打开下一个标记“<...> 一些文本 <...>”如何将他应用于Rubby - 我不知道
Regex will be:
<[^>]*>([^<]*)
<[^>]*>
- math thiw first tag "<...>"([^<]*)
- capture text to open next tag "<...> some text <...>"how apply him on Rubby - i dont know
相关问答
更多-
为什么我应该使用content_tag而不是“常规”html?(why should I use content_tag instead of “regular” html?)[2022-04-22]
能够使用content_tag有助于在Ruby代码中编程生成HTML,例如:助手和演示者。 在我看来,我通常不会在项目的布局和模板中使用content_tags - 我认为它不会帮助编码的可读性。 在这里,我看不到任何生产力或表现的收益。 但是:建议的意思:如果这就是你的团队已经标准化的东西 - 与团队一起去。 Being able to use the content_tag helps when you are programmatically generating HTML inside of rub ... -
在第一个标记之前获取HTML(Getting HTML before first
tag)[2022-11-28]$content = "this is my content
as it continues
another break tag"; $parts = explode("
", $content); $first = trim($parts[0]); 爆炸功能: http : //php.net/manual/en/function.explode.php 按字符串拆分字符串 修剪功能: http : //www.php.net/manual/en/function. ... -
我在我的PHP代码中遇到此错误以显示og文件。 我想,它会在轨道上工作。 你只需将""改成'' 要么 我希望这对你有帮助。 I have ever got this error in my php code to ...