我有一個字符串,它看起來就像這樣:像正則表達式找到的UUID和文本
"name=Guy&Id=e8679b5a-bf27-46c6-aaf0-ef0eced1945e&Family.Id=e8679b5a-bf27-46c6-aaf0-ef0eced1945e,aaa79b5a-bf27-46c6-aaf0-ef0eced1945e,eee79b5a-bf27-46c6-aaf0-ef0eced1945e&Children.Id=bbb79b5a-bf27-46c6-aaf0-ef0eced1945e,ccc79b5a-bf27-46c6-aaf0-ef0eced1945e,ddd79b5a-bf27-46c6-aaf0-ef0eced1945e&Father.Id=fff79b5a-bf27-46c6-aaf0-ef0eced1945e"
我想有一個正則表達式,將發現所有的組合(String.Id和他們的UUID):
Family | e8679b5a-bf27-46c6-aaf0-ef0eced1945e,aaa79b5a-bf27-46c6-aaf0-ef0eced1945e,vvv79b5a-bf27-46c6-aaf0-ef0eced1945e
Children | bbb79b5a-bf27-46c6-aaf0-ef0eced1945e,ccc79b5a-bf27-46c6-aaf0- ef0eced1945e,ddd79b5a-bf27-46c6-aaf0-ef0eced1945e
Father | fff79b5a-bf27-46c6-aaf0-ef0eced1945e
我想在PostgreSQL分析這個,現在我可以分析它的一些,但不是全部:
SELECT
regexp_matches('"name=Guy&Id=e8679b5a-bf27-46c6-aaf0-ef0eced1945e&Family.Id=e8679b5a-bf27-46c6-aaf0-ef0eced1945e,aaa79b5a-bf27-46c6-aaf0-ef0eced1945e,vvv79b5a-bf27-46c6-aaf0-ef0eced1945e&Children.Id=bbb79b5a-bf27-46c6-aaf0-ef0eced1945e,ccc79b5a-bf27-46c6-aaf0-ef0eced1945e,ddd79b5a-bf27-46c6-aaf0-ef0eced1945e&Father.Id=fff79b5a-bf27-46c6-aaf0-ef0eced1945e"'
,'&(\w*)\.Id=([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})', 'g')::text
感謝
你使用什麼語言/工具? –
我想在postgreSQL中做這個正則表達式,但任何語言都應該沒問題:)即使在這裏:https://regex101.com/ – Gen4ik
從一個記錄到很多SQL可能會非常棘手。 –