如何组合以下正则表达式
How to combine the following regex?
所以基本的想法是我想将以下内容分为 3 个部分,描述文本、html 代码和脚本代码:
---
name: Accordion
description: |
### What
Puts modules of content into a linear stack of panels that can be closed and opened independently of each other. The accordion also helps in shortening a page and making it more scannable.
### Use when
The content modules are mutually exclusive. Content modules can consist of a list of items, links or text blocks.
---
<!-- Accordion-->
<div class="ui-accordion">
some html
</div>
<!-- / Accordion -->
<script>
some code
</script>
目前我已经能够将其分为两部分,但它还包括需要在第三部分中的脚本部分。
^(-{3}(?:'n|'r)(['w'W]+?)-{3})?(['w'W]*)
我试过这种方式,但没有工作
^(-{3}(?:'n|'r)(['w'W]+?)-{3})?(['w'W]*)(<script.*?>(['s'S]*?)<'/script>)
有什么建议吗?
我需要的确切输出如下:
### What
Puts modules of content into a linear stack of panels that can be closed and opened independently of each other. The accordion also helps in shortening a page and making it more scannable.
### Use when
The content modules are mutually exclusive. Content modules can consist of a list of items, links or text blocks.
<!-- Accordion-->
<div class="ui-accordion">
some html
</div>
<!-- / Accordion -->
some code
但它需要分为 3 组。
试试这个:
(?:---['s'n'r]*((?:.|['n'r's])*)(?=['s'r'n]+---)['s'r'n]+---)?(?:(?=['n'r's]+<!--['s]*Accordion['s]*-->)['s'r'n]+<!--['s*]Accordion['s]*-->['s'n'r]*((?:.|['n'r's])*)(?=['s'r'n]*<!--['s]*'/ Accordion['s]*-->)['s'r'n]+<!--['s]*'/ Accordion['s]*-->)?(?:(?:.|['n'r's])*(?=<script>)<script>['s'r'n]*((?:.|['n'r's])*)(?=['s'r'n]*<'/script>)['s'r'n]+<'/script>)?
请注意,这严格限于输入中的一些内容(注释用"---"包装,注释以 开头/结尾)。可能需要进行调整以适应更自由的比赛。
相关文章:
- 组合angularjs表单字段的两个正则表达式
- 在 JS 中组合两个正则表达式
- 在 JavaScript 中组合正则表达式
- 用于在组合文件中查找 AMD 定义呼叫的正则表达式
- 如何在字符串上组合JS replace()方法中的3个正则表达式模式
- 两个正则表达式的组合
- 如何组合以下正则表达式
- 正则表达式“gi”修饰符的组合不适用于单个单词
- 将两个正则表达式组合在一起
- 两个正则表达式的组合
- 组合2个正则表达式,其中一个使用OR运算符进行精确匹配
- 如何创建正则表达式javascript函数来匹配特定的字符串组合
- 将正则表达式组合为空格和换行符
- 正在尝试组合exlude和include正则表达式
- 在Javascript中组合正则表达式
- 在OR中将正则表达式组合在一起
- 用于字符串组合和序列规则的正则表达式角2
- 使用or组合两个正则表达式条件
- 用于字母/数字组合的正则表达式
- 正则表达式 - 组合正则表达式 - 字符串的开头和结尾