Thx JJ, that works great!

On Monday, 5 December 2022 at 21:45:30 UTC+1 jj wrote:

> Hi Marcel,
>
> You could try this.
>
> Find:
>
>    
>  
> (?s)(<note(?:.(?!</note>))+)(<dynamics.+?</dynamics>)\n((?:.(?!<note))+</note>)
>
> Replace:
>
>     
> <direction>\n<direction-type>\n\2\n</direction-type>\n</direction>\n\1\3
>
> HTH
>
> Jean Jourdain
> On Monday, December 5, 2022 at 8:27:49 PM UTC+1 Marcel Lamers wrote:
>
>> 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 "[email protected]" 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/125a0d7f-cda4-478d-b617-b1697d9f70e1n%40googlegroups.com.

Reply via email to