INNER CODE UNIT · Python
is_comment_line
ArcSurge/Termius-Pro-zh_CN · lang.py:219
def is_comment_line(line):
"""判断是否为注释行(以 # 开头)"""
return line.strip().startswith("#")
def is_regex_pattern(s):
"""判断是否为正则表达式模式(/pattern/ 格式,排除 // 注释)"""
return len(s) > 1 and s.startswith("/") and s.endswith("/") and "//" not in s
def parse_replace_rule(rule):
"""解析替换规则:原字符串|新字符串
使用 | 作为分隔符,最多分割一次以支持替换内容中包含 |
"""
if "|" not in rule:
raise ValueError("Invalid replacement rule format.")
return rule.split("|", 1)