fork download
  1. import re
  2.  
  3. s=""" ### http://w...content-available-to-author-only...e.com/pms/datamodel/v1#AAAAAAAAAAAAAAAAAAAA
  4. pms:ecCreatedBy rms:type owl:ObjectProperty ;
  5. rmfs:domain pms:Engineering ;
  6. rmfs:range pms:Person ;
  7. rmfs:label "Ersteller"@ce ,
  8. "AAAAAAAAAAAAAAAAAAAA"@en .
  9.  
  10. ### http://w...content-available-to-author-only...e.com/pms/datamdl2/v1#ecCreatedBy
  11. pms:ecCreatedBy rms:type owl:ObjectProperty ;
  12. rmfs:domain pms:Engineering ;
  13. rmfs:range pms:Person ;
  14. rmfs:label "BBBBBBBBBBBBBBBB"@en ,
  15. "Ersteller"@ce ."""
  16.  
  17. # s is the file contents. Read:
  18. # with open(filepath, 'r') as fr:
  19. # s=fr.read()
  20. s = re.sub(r'(?m)(rmfs:label\s*)("[^"]*"@(?!en)\w*)(\s*,\s*)("[^"]*"@en) \.$', r'\1\4\3\2 .', s)
  21. s = re.sub(r'(?m)^(\s*###\s*http.*/v\d+#)\w*((?:\n(?!\n).*)*rmfs:label\s*")([^"]*)("@en)', r'\1\3\2\3\4', s)
  22. print(s)
  23. # Wrtie to file:
  24. # with open(filepath, 'w') as fw:
  25. # fw.write(s)
Success #stdin #stdout 0.02s 27712KB
stdin
Standard input is empty
stdout
 ###  http://w...content-available-to-author-only...e.com/pms/datamodel/v1#AAAAAAAAAAAAAAAAAAAA
pms:ecCreatedBy rms:type owl:ObjectProperty ;
                rmfs:domain pms:Engineering ;
                rmfs:range pms:Person ;
                rmfs:label "AAAAAAAAAAAAAAAAAAAA"@en ,
                "Ersteller"@ce .

   ###  http://w...content-available-to-author-only...e.com/pms/datamdl2/v1#BBBBBBBBBBBBBBBB
pms:ecCreatedBy rms:type owl:ObjectProperty ;
                rmfs:domain pms:Engineering ;
                rmfs:range pms:Person ;
                rmfs:label "BBBBBBBBBBBBBBBB"@en ,
                           "Ersteller"@ce .