I have a string of data which looks like this which is on one line.
<record xmlns:f="http://abc.com/">
<f:Table><f:Row><f:Cell>#1</f:Cell></f:Row><f:Row><f:Cell>Data 222</f:Cell></f:Row><f:Row> <f:Cell>Version: v3</f:Cell></f:Row><f:Row><f:Cell>Serial Number: 000000000</f:Cell></f:Row> <f:Row><f:Cell>Signature: 123</f:Cell></f:Row><f:Row><f:Cell>Issuer:</f:Cell></f:Row><f:Row> <f:Cell>C=EE,</f:Cell></f:Row><f:Row><f:Cell>ST=ABC,</f:Cell></f:Row><f:Row><f:Cell>L=avavv,</f:Cell></f:Row><f:Row><f:Cell><f:HexDump><f:Line seq=""0x0000"" hex=""09 09 4f 3d 5a 65 72 6f 54 75 72 6e 61 72 6f 75"">..O=ABC</f:Line><f:Line seq=""0x0010"" hex=""6e 64 20 4f c3 9c 2c"">nd OÇ.,</f:Line></f:HexDump></f:Cell></f:Row><f:Row><f:Cell>OU=abc,</f:Cell></f:Row><f:Row><f:Cell>CN=trtrtrtr,</f:Cell></f:Row><f:Row><f:Cell>E=null,</f:Cell></f:Row><f:Row><f:Cell>Create: 03/03/2010 14:58</f:Cell></f:Row><f:Row><f:Cell>Expire: 04/02/2010 14:58</f:Cell></f:Row><f:Row><f:Cell>Subject:</f:Cell></f:Row><f:Row><f:Cell>C=EE,</f:Cell></f:Row><f:Row><f:Cell>ST=SS,</f:Cell></f:Row><f:Row><f:Cell>L=Tartu,</f:Cell></f:Row><f:Row><f:Cell><f:HexDump><f:Line seq=""0x0000"" hex=""09 09 4f 3d 5a 65 72 6f 54 75 72 6e 61 72 6f 75"">..O=ZeroTurnarou</f:Line><f:Line seq=""0x0010"" hex=""6e 64 20 4f c3 9c 2c"">nd OÇ.,</f:Line></f:HexDump></f:Cell></f:Row><f:Row><f:Cell>OU=KKK,</f:Cell></f:Row></f:Table>
My Ruby Regular expresion looks like this:
<f:HexDump>[\s\S]*,<\/f:Line><\/f:HexDump>
So I'm trying to remove everything (including the tags) between both of the <f:HexDump> and <f:/HexDump> tags but leaving the stuff in between.
The problem is my regex is selecting everything in between right up to the second <f:/HexDump> tag.
<f:HexDump><f:Line seq=""0x0000"" hex=""09 09 4f 3d 5a 65 72 6f 54 75 72 6e 61 72 6f 75"">..O=ABC</f:Line><f:Line seq=""0x0010"" hex=""6e 64 20 4f c3 9c 2c"">nd OÇ.,</f:Line></f:HexDump></f:Cell></f:Row><f:Row><f:Cell>OU=abc,</f:Cell></f:Row><f:Row><f:Cell>CN=trtrtrtr,</f:Cell></f:Row><f:Row><f:Cell>E=null,</f:Cell></f:Row><f:Row><f:Cell>Create: 03/03/2010 14:58</f:Cell></f:Row><f:Row><f:Cell>Expire: 04/02/2010 14:58</f:Cell></f:Row><f:Row><f:Cell>Subject:</f:Cell></f:Row><f:Row><f:Cell>C=EE,</f:Cell></f:Row><f:Row><f:Cell>ST=SS,</f:Cell></f:Row><f:Row><f:Cell>L=Tartu,</f:Cell></f:Row><f:Row><f:Cell><f:HexDump><f:Line seq=""0x0000"" hex=""09 09 4f 3d 5a 65 72 6f 54 75 72 6e 61 72 6f 75"">..O=ZeroTurnarou</f:Line><f:Line seq=""0x0010"" hex=""6e 64 20 4f c3 9c 2c"">nd OÇ.,</f:Line></f:HexDump>
Can this be done using Ruby regular expressions?
""? Luckily, that can be fixed with a string replacement :) (If it's not that, then what errors does nokogiri give you?)