tags:

views:

15

answers:

2

I have the following lines showing up in files that have been converted to XML from an Excel worksheet:

 <Worksheet ss:Name="Sheet1">
  <Names>
   <NamedRange ss:Name="Print_Area" ss:RefersTo="=Sheet1!R30C1:R8642C15"/>
  </Names>
  <Table ss:ExpandedColumnCount="14" ss:ExpandedRowCount="8655" x:FullColumns="1"
   x:FullRows="1" ss:StyleID="s16">
   <Column ss:Index="2" ss:StyleID="s16" ss:AutoFitWidth="0" ss:Width="41.25"/>
   <Column ss:StyleID="s16" ss:AutoFitWidth="0" ss:Width="36"/>
   <Column ss:StyleID="s16" ss:AutoFitWidth="0" ss:Width="35.25"/>
   <Column ss:StyleID="s16" ss:AutoFitWidth="0" ss:Width="38.25" ss:Span="1"/>
   <Column ss:Index="8" ss:StyleID="s16" ss:AutoFitWidth="0" ss:Width="31.5"/>
   <Column ss:Index="11" ss:StyleID="s16" ss:AutoFitWidth="0" ss:Width="30"/>
   <Column ss:StyleID="s16" ss:AutoFitWidth="0" ss:Width="33.75"/>
   <Column ss:StyleID="s16" ss:AutoFitWidth="0" ss:Width="28.5"/>
   <Row ss:StyleID="s18">
    <Cell ss:StyleID="s17"><Data ss:Type="String">UNITED STATES</Data></Cell>
    <Cell ss:StyleID="s17"/>
    <Cell ss:StyleID="s17"/>
    <Cell ss:StyleID="s17"/>
    <Cell ss:StyleID="s17"/>
    <Cell ss:StyleID="s17"/>
    <Cell ss:StyleID="s17"/>
   </Row>

I am attempting to only remove the <Column .. /> lines. I "thought" I had a pretty good handle on Regular Expressions in VB.NET, but I cannot seem to match these lines. I have tried the following match strings:

'Using (RegexOptions.Multiline)
Private Const Column_MatchExpression As String = "^[\s]*<Column[\s\S]+$"
Private Const Column_MatchExpression As String = "   <Column[\s\S]+$"
Private Const Column_MatchExpression As String = "^   <Column[\s\S]+$"
Private Const Column_MatchExpression As String = "^[\s]+<Column[\s\w\W]+$"

Any thoughts on the matter would be appreciated.

A: 

What about

"^\s*<Column.*/>\s*$"

?

Frank
This did the trick, thanks for the suggestion!
knslyr
A: 
\<Column[^>]*\>

Should work

Justin Wignall
Tried this, unfortunately didn't work.
knslyr
OK.. works fine for me, glad you got your answer though. Check out http://www.nregex.com/nregex/default.aspx as a quick and easy (and free) online tool for regex testing
Justin Wignall