G
Gabriel Rossetti
Hello everyone,
I'm going nuts with some regex, could someone please show me what I'm
doing wrong?
I have an XMPP msg :
<message xmlns='jabber:client' to='(e-mail address removed)'>
<mynode xmlns='myprotocol:core' version='1.0' type='mytype'>
<parameters>
<param1>123</param1>
<param2>456</param2>
</parameters>
<payload type='plain'>...</payload>
</mynode>
<x xmlns='jabber:x:expire' seconds='15'/>
</message>
the <parameter> node may be absent or empty (<parameter/>), the <x> node
may be absent. I'd like to grab everything exept the <payload> nod and
create something new using regex, with the XMPP message example above
I'd get this :
<message xmlns='jabber:client' to='(e-mail address removed)'>
<mynode xmlns='myprotocol:core' version='1.0' type='mytype'>
<parameters>
<param1>123</param1>
<param2>456</param2>
</parameters>
</mynode>
<x xmlns='jabber:x:expire' seconds='15'/>
</message>
for some reason my regex doesn't work correctly :
r"(<message .*?>).*?(<mynode
..*?>).*?(?<parameters>.*?</parameters>)|<parameters/>)?.*?(<x .*/>)?"
I group the opening <message> node, the opening <mynode> node and if the
xmlns='myprotocol:core' version='1.0'
type='mytype'><parameters><param1>123</param1><param2>456</param2></parameters><payload
xmlns='myprotocol:core' version='1.0'
type='mytype'><parameters/><payload
xmlns='myprotocol:core' version='1.0' type='mytype'><payload
xmlns='myprotocol:core' version='1.0'
xmlns='myprotocol:core' version='1.0'
xmlns='myprotocol:core' version='1.0' type='mytype'><payload
("<message xmlns='jabber:client' to='(e-mail address removed)'>", "<mynode
xmlns='myprotocol:core' version='1.0' type='mytype'>",
("<message xmlns='jabber:client' to='(e-mail address removed)'>", "<mynode
xmlns='myprotocol:core' version='1.0' type='mytype'>",
Does someone know what is wrong with my expression? Thank you, Gabriel
I'm going nuts with some regex, could someone please show me what I'm
doing wrong?
I have an XMPP msg :
<message xmlns='jabber:client' to='(e-mail address removed)'>
<mynode xmlns='myprotocol:core' version='1.0' type='mytype'>
<parameters>
<param1>123</param1>
<param2>456</param2>
</parameters>
<payload type='plain'>...</payload>
</mynode>
<x xmlns='jabber:x:expire' seconds='15'/>
</message>
the <parameter> node may be absent or empty (<parameter/>), the <x> node
may be absent. I'd like to grab everything exept the <payload> nod and
create something new using regex, with the XMPP message example above
I'd get this :
<message xmlns='jabber:client' to='(e-mail address removed)'>
<mynode xmlns='myprotocol:core' version='1.0' type='mytype'>
<parameters>
<param1>123</param1>
<param2>456</param2>
</parameters>
</mynode>
<x xmlns='jabber:x:expire' seconds='15'/>
</message>
for some reason my regex doesn't work correctly :
r"(<message .*?>).*?(<mynode
..*?>).*?(?<parameters>.*?</parameters>)|<parameters/>)?.*?(<x .*/>)?"
I group the opening <message> node, the opening <mynode> node and if the
xmlns='myprotocol:core' version='1.0'
type='mytype'><parameters><param1>123</param1><param2>456</param2></parameters><payload
xmlns='myprotocol:core' version='1.0'
type='mytype'><parameters/><payload
xmlns='myprotocol:core' version='1.0' type='mytype'><payload
xmlns='myprotocol:core' version='1.0'
xmlns='myprotocol:core' version='1.0'
xmlns='myprotocol:core' version='1.0' type='mytype'><payload
("<message xmlns='jabber:client' to='(e-mail address removed)'>", "<mynode
xmlns='myprotocol:core' version='1.0' type='mytype'>",
("<message xmlns='jabber:client' to='(e-mail address removed)'>", "<mynode
xmlns='myprotocol:core' version='1.0' type='mytype'>",
Does someone know what is wrong with my expression? Thank you, Gabriel