I need to substitute owl:Class in the following text with the LP number
Input
<owl:Class rdf:about="https://loinc.org/LP173100-1">
<rdfs:subClassOf rdf:resource="https://loinc.org/LP410935-3"/>
<rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Counseling (LP)</rdfs:label>
<skos:prefLabel rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Counseling</skos:prefLabel>
<loinc:hasCode rdf:datatype="http://www.w3.org/2001/XMLSchema#string">LP173100-1</loinc:hasCode>
</owl:Class>
so that the substituted output looks like the following
Output
<LP173100-1 rdf:about="https://loinc.org/LP173100-1">
<rdfs:subClassOf rdf:resource="https://loinc.org/LP410935-3"/>
<rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Counseling (LP)</rdfs:label>
<skos:prefLabel rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Counseling</skos:prefLabel>
<loinc:hasCode rdf:datatype="http://www.w3.org/2001/XMLSchema#string">LP173100-1</loinc:hasCode>
</LP173100-1>
I have used s/\(owl:Class\)\(.*org\/\)\(LP.*\)"/\3\2\3/g
for the first line but I don't know how to apply it on the last line. Is there a more elegant solution? I have a huge file where I need to do such substitution.
I am using a Centos OS 7.7 Linux machine.