sql查询以提取所有非数量序列

问题描述 投票:0回答:1

在Mariadb 10.6.20上工作。我正在尝试从字符列中的字符串中提取所有独特的非数字序列。

样本数据:

(555) 444 3322 +(1.400) - 200-4044 ext200
指望输出:

( ) +( . ) - - ext
我有这个查询:

WITH RECURSIVE phone_parts AS ( SELECT phone, REGEXP_SUBSTR(phone, '[^0-9]+') AS non_digit_sequence, SUBSTRING(phone, LENGTH(REGEXP_SUBSTR(phone, '[^0-9]+')) + 1) AS remaining_phone FROM chars WHERE phone REGEXP '[^0-9]' UNION ALL SELECT phone, REGEXP_SUBSTR(remaining_phone, '[^0-9]+'), SUBSTRING(remaining_phone, LENGTH(REGEXP_SUBSTR(remaining_phone, '[^0-9]+')) + 1) FROM phone_parts WHERE remaining_phone != '' ) SELECT DISTINCT non_digit_sequence FROM phone_parts WHERE non_digit_sequence IS NOT NULL ORDER BY non_digit_sequence;

但它返回”) - 和“  - ”,即使它们是同一序列的一部分。
任何想法如何解决?

thanks!

CREATE TABLE test SELECT '(555) 444 3322' phone UNION ALL SELECT '+(1.400) - 200-4044 ext200'; SELECT phone, REGEXP_REPLACE(phone, '\\d+', '\n') FROM test;
sql mariadb
1个回答
0
投票

手机regexp_replace(电话,'\ d+',',' ')(555)4443322(+(1.400)-200-4044Ext200+() - Fiddle



.-
ext



最新问题
© www.soinside.com 2019 - 2025. All rights reserved.