How can SQL detect an absent field delimiter?

instr returns the one-based position of the first match, or zero when the delimiter is absent.

SQLite example and interpretation

Check the equals sign before slicing key=value. Treating zero as a usable position could silently accept malformed records.

SELECT instr('run=17','='),instr('broken','=');

Result [[4, 0]]

中文

日志字段缺少分隔符时怎样识别?

instr 返回首次命中的一基位置,找不到则返回零。

SQLite 示例与适用条件

读取 key=value 前先检查等号位置。若把零直接用于切片,损坏的记录可能被悄悄当成有效字段。

SELECT instr('run=17','='),instr('broken','=');

结果 [[4, 0]]

References / 参考来源

Keep reading / 继续阅读