It gets much simpler if I add e.g. a ! before every </note> first.
I can then search for
(<note>)([^!]+)(<dynamics>)([^!]+)(</dynamics>)

On Monday, 5 December 2022 at 17:13:42 UTC+1 Marcel Lamers wrote:

> Hi,
>
> I have a musicxml file that is not properly imported into my music 
> notation app and I have to change the syntax to do a better import.
> I gave it a go with grep but can't seem to get the proper pattern to make 
> the change.
>
> In short, I want to remove the dynamics tags plus content from a note tag 
> and place it before the note tag with new closing tags.
> Difficulty is the occurrence of several <note> tags and the greediness of 
> the patterns I tested.
> I also gave the must not occur <note>(?!</note>) a go but to no avail. Any 
> help in the matter would be greatly appreciated
>
> Here is an example:
>
> before
>
> <!--//////////////////// Part 22 | Measure 39 ////////////////////-->
> <measure number="39">
> <attributes>
> <divisions>48</divisions>
> </attributes>
> <note>
> <pitch>
> <step>D</step>
> <octave>6</octave>
> </pitch>
> <duration>48</duration>
> <voice>1</voice>
> <type>quarter</type>
> <staff>1</staff>
> </note>
> <note>
> <pitch>
> <step>G</step>
> <octave>5</octave>
> </pitch>
> <duration>48</duration>
> <voice>1</voice>
> <type>quarter</type>
> <staff>1</staff>
> </note>
> <note>
> <pitch>
> <step>D</step>
> <octave>5</octave>
> </pitch>
> <duration>48</duration>
> <voice>1</voice>
> <type>quarter</type>
> <staff>1</staff>
> </note>
> <direction>
> <direction-type>
> <wedge type="stop"/>
> </direction-type>
> </direction>
> <note>
> <pitch>
> <step>G</step>
> <octave>5</octave>
> </pitch>
> <duration>48</duration>
> <voice>1</voice>
> <type>quarter</type>
> <staff>1</staff>
> <notations>
> <slur type="stop" number="1"/>
>
>
> *<dynamics><f/></dynamics>*
> </notations>
> </note>
> </measure>
> <!--//////////////////// Part 22 | Measure 40 ////////////////////-->
>
> after
>
> <!--//////////////////// Part 22 | Measure 39 ////////////////////-->
> <measure number="39">
> <attributes>
> <divisions>48</divisions>
> </attributes>
> <note>
> <pitch>
> <step>D</step>
> <octave>6</octave>
> </pitch>
> <duration>48</duration>
> <voice>1</voice>
> <type>quarter</type>
> <staff>1</staff>
> </note>
> <note>
> <pitch>
> <step>G</step>
> <octave>5</octave>
> </pitch>
> <duration>48</duration>
> <voice>1</voice>
> <type>quarter</type>
> <staff>1</staff>
> </note>
> <note>
> <pitch>
> <step>D</step>
> <octave>5</octave>
> </pitch>
> <duration>48</duration>
> <voice>1</voice>
> <type>quarter</type>
> <staff>1</staff>
> </note>
> <direction>
> <direction-type>
> <wedge type="stop"/>
> </direction-type>
> </direction>
>
>
>
>
>
>
>
>
> *<direction><direction-type><dynamics><f/></dynamics></direction-type></direction>*
> <note>
> <pitch>
> <step>G</step>
> <octave>5</octave>
> </pitch>
> <duration>48</duration>
> <voice>1</voice>
> <type>quarter</type>
> <staff>1</staff>
> <notations>
> <slur type="stop" number="1"/>
> </notations>
> </note>
> </measure>
> <!--//////////////////// Part 22 | Measure 40 ////////////////////-->
>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/10227a12-e144-4d6b-b6ff-05d6140ed85cn%40googlegroups.com.

Reply via email to