package com.example.firstapp.entity
|
|
data class Rule(var type: String,var content: String ,var reg: String) {
|
|
// 在 Rule 类中定义提取方法
|
fun extractCodeFromMessage(message: String): String? {
|
// 如果 message 包含 content
|
if (message.contains(content)) {
|
// 使用 reg 作为正则表达式进行匹配
|
val regex = reg.toRegex()
|
val matchResult = regex.find(message)
|
return matchResult?.value // 如果找到匹配的内容,则返回
|
}
|
return null // 如果不匹配,返回 null
|
}
|
|
}
|