我有一个格式如此的SQL文档(它有大约3000个条目,如此):
INSERT INTO DATA(UUID, IS_SIMULATED, ENVIRONMENT) VALUES('99b857afcb2e4f7dbf8657ea916ad9d7',FALSE,'SPACE')
INSERT INTO DATA(UUID, IS_SIMULATED, ENVIRONMENT) VALUES('df8480e333c044f08ada939c66fa13f5',FALSE,'AIR')
INSERT INTO DATA(UUID, IS_SIMULATED, ENVIRONMENT) VALUES('ad3e38a5e28f40ba8234bb8727936963',FALSE,'SURFACE')
INSERT INTO DATA(UUID, IS_SIMULATED, ENVIRONMENT) VALUES('58f23ec0b9d141ed89dba8ce2f0fd377',FALSE,'SUBSURFACE')
INSERT INTO DATA(UUID, IS_SIMULATED, ENVIRONMENT) VALUES('244182c8e53247529bd55f54c527bdbf',FALSE,'LAND')
我需要格式化所有UUID字符串以包含破折号,如下所示:
550e8400-e29b-41d4-a716-446655440000
有没有一种简单的方法来解析这个并按照我需要的方式格式化UUID而不用手工操作?
答案 0 :(得分:3)
试试这个正则表达式:
'([0-9a-f]{8})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{12})'
并按'$1-$2-$3-$4-$5'
替换匹配。