mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-27 22:00:24 +08:00
正则表达式填写多行时提示用户需要转换成竖杠(|)符号
This commit is contained in:
@@ -116,6 +116,7 @@
|
||||
|
||||
<!-- 其余数据 -->
|
||||
<textarea rows="3" maxlength="4096" name="value" v-model="rule.value" @input="changeRuleValue" v-else></textarea>
|
||||
<p class="comment" v-if="(rule.operator == 'match' || rule.operator == 'not match') && rule.value.match(/\n/)"><span class="red">警告:发现你填写的正则表达式中包含了换行符,如果你的意图是每行都表示不同的选项,那么请使用竖杠(<code-label>|</code-label>)符号代替换行符,比如把<code-label>a换行b换行c换行</code-label>改成<code-label>a|b|c</code-label>,<a href="" @click.prevent="convertValueLine">[帮我转换]</a>。</span></p>
|
||||
|
||||
<!-- 特殊规则 -->
|
||||
<div style="margin-top: 1em">
|
||||
|
||||
@@ -122,6 +122,21 @@ Tea.context(function () {
|
||||
}
|
||||
}
|
||||
|
||||
this.convertValueLine = function () {
|
||||
let value = this.rule.value
|
||||
if (value != null && value.length > 0) {
|
||||
let lines = value.split(/\n/)
|
||||
let resultLines = []
|
||||
lines.forEach(function (line) {
|
||||
line = line.trim()
|
||||
if (line.length > 0) {
|
||||
resultLines.push(line)
|
||||
}
|
||||
})
|
||||
this.rule.value = resultLines.join("|")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 正则测试
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user