fork download
  1. import re
  2.  
  3. string = """
  4. Name: Clash1
  5. Distance: -1.341m
  6. Image Location: Test 1_navis_files\cd000001.jpg
  7. HardStatus: New
  8. Clash Point: 3.884m, -2.474m, 2.659m
  9. Date Created: 2016/6/2422:45:09
  10.  
  11. Item 1
  12. GUID: 6efaec51-b699-4d5a-b947-505a69c31d52
  13. Path: File ->Colisiones_v2015.dwfx ->Segment ->Pipes (1) ->Pipe Types (1) ->Default (1) ->Pipe Types [2463] ->Shell
  14. Item Name: Pipe Types [2463]
  15. Item Type: Shell
  16.  
  17. Item 2
  18. GUID: 6efaec51-b699-4d5a-b947-505a69c31dea
  19. Path: File ->Colisiones_v2015.dwfx ->Segment ->Walls (4) ->Basic Wall (4) ->Wall 1 (4) ->Basic Wall [2343] ->Shell
  20. Item Name: Basic Wall [2343]
  21. Item Type: Shell
  22.  
  23. ------------------
  24.  
  25.  
  26. Name: Clash2
  27. Distance: -1.341m
  28. Image Location: Test 1_navis_files\cd000002.jpg
  29. HardStatus: New
  30. Clash Point: 3.884m, 3.533m, 2.659m
  31. Date Created: 2016/6/2422:45:09
  32.  
  33. Item 1
  34. GUID: 6efaec51-b699-4d5a-b947-505a69c31d52
  35. Path: File ->Colisiones_v2015.dwfx ->Segment ->Pipes (1) ->Pipe Types (1) ->Default (1) ->Pipe Types [2463] ->Shell
  36. Item Name: Pipe Types [2463]
  37. Item Type: Shell
  38.  
  39. Item 2
  40. GUID: 6efaec51-b699-4d5a-b947-505a69c31de8
  41. Path: File ->Colisiones_v2015.dwfx ->Segment ->Walls (4) ->Basic Wall (4) ->Wall 1 (4) ->Basic Wall [2341] ->Shell
  42. Item Name: Basic Wall [2341]
  43. Item Type: Shell
  44.  
  45. ------------------
  46. """
  47.  
  48. rx = re.compile(r"""
  49. ^Name:\s*
  50. (?P<name>.+)
  51. [\s\S]+?
  52. ^Clash\ Point:\s*
  53. (?P<point>.+)""", re.VERBOSE|re.MULTILINE)
  54. for match in rx.finditer(string):
  55. print match.group('name')
  56. print match.group('point')
Success #stdin #stdout 0.01s 8968KB
stdin
Standard input is empty
stdout
Clash1
3.884m, -2.474m, 2.659m
Clash2
3.884m, 3.533m, 2.659m