parse 字段(可能使用 regex)时
有一个 MySQL (MySQL v8) 表,其中一列包含长字符串信息,但当选择它时,只需要检索长字符串的特定部分。
需要将紧接在 “ - ” 部分之前和该部分之后的值作为响应的一部分(除非字符串的开头,在这种情况下没有
)
create table codes (
id integer primary key
desc text not null
);
insert into codes values (1, '423.9 - This is the first item<Br>511.9 - This is the second item<Br>486 - This is the third item (486.0 actually)<Br>42.a.7.31 - <Br>785.0 - 785.? unsure if decimal is correct')
insert into codes values (2, '428.0M - CHF NOS')
insert into codes values (3, 'E.423.9 - Just testing!<Br>511.9 - Another test 12345')
需要紧接在 ' - ' 部分之前的描述部分,例如在“select ...from codes“我会有这个:
423.9, 511.9, 486, 42.a.7.31, 785.0
428.0M
E.423.9, 511.9