View Single Post
Old 09-28-2012, 02:16 AM   #1
cybmole
Wizard
cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.
 
Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
help with hard regex please

this is a regex question - not really a sigil one, but since this is where the helpful regex experts are, I'm hoping one will step in and advise

I want to clean up some .xml files & am thinking regex in notepad++ could do the job if I can figure out the expression.

I want to zap all chunks that look like the example below, where the key search term is X-Fi.

for anything with X-Fi in that 2nd line I want to delete the whole block- ambitious I know but can that be done ?

<RemoteButton>
<Name>X-Fi 24-bit Wheel Button</Name>
<MidiSignal>0A 41 44 09 76</MidiSignal>
<USBSignal>02 C1 44 89 76</USBSignal>
<ButtonType>btKeyboardEvent</ButtonType>
<KeyCode>173</KeyCode>
</RemoteButton>

logically, I have to find the start phrase <RemoteButton>\s*<Name>X-Fi , look forward to locate the matching </Remote... & delete everything found in between. I also have to cope with intermediate line feeds, white space & / characters..

hmm - I seem to be solving my own question as i type...

will a simple (.*) suffice i.e. find
<RemoteButton>\s*<Name>X-Fi(.*)</RemoteButton>


well i can load the xml into sigil & the above almost works, ( it leaves some mysterious de> entries ) but I can't see how to then save as xml ( sigil v4)

i try the same expression in notepad++ & it does NOT work - either N+= cannot do multi-line or it uses different regex syntax ?

Last edited by cybmole; 09-28-2012 at 02:33 AM.
cybmole is offline   Reply With Quote