oracle 如何使用plsql在文本中显示精确的10位数值?

4uqofj5v  于 2023-10-16  发布在  Oracle
关注(0)|答案(1)|浏览(174)
SELECT carddetails 
FROM cc_emp_card 
WHERE  REGEXP_LIKE ( carddetails,'[[:digit:]]{10}?([^[:digit:]])');

电流输出:

FT 6820220419001794 xxx asdfwf 2 BIM 2022
FT 6820220419001796 xsdjcc jcw 2 BIM 2022
FT 6820220419001796 ajscbjk , c dk2 BIM 2022
000006650445/Business Meals (Staff with Externals)
5010083131,1234567890
1234567890
5010009921 dcbjwk ft 4959 29.04
5010018300 Dmdbchbk jdkjw 11 del 09.05
5000630739 dbcwbdj FT 9/001 DEL 13.05
5010015146 mnwd chjw    FT 4 DEL 29.04.22

预期输出:

5010083131,1234567890
1234567890
5010009921 dcbjwk ft 4959 29.04
5010018300 Dmdbchbk jdkjw 11 del 09.05
5000630739 dbcwbdj FT 9/001 DEL 13.05
5010015146 mnwd chjw    FT 4 DEL 29.04.22
gpnt7bae

gpnt7bae1#

您应该将这些数字 * 锚 * 到字符串的开头:

SQL> SELECT carddetails
  2    FROM cc_emp_card
  3   WHERE REGEXP_LIKE (carddetails, '^[[:digit:]]{10}?([^[:digit:]])');
                                       |
                                      this!

CARDDETAILS
--------------------------------------------------
5010009921 dcbjwk ft 4959 29.04
5010018300 Dmdbchbk jdkjw 11 del 09.05
5000630739 dbcwbdj FT 9/001 DEL 13.05
5010015146 mnwd chjw    FT 4 DEL 29.04.22

SQL>

相关问题