views:

103

answers:

1

I'm trying to eliminate HTML tags from a value displayed in an ssrs report.

My solution came to: =(new System.Text.RegularExpressions.Regex("<[^>]*>")).Replace((new System.Text.RegularExpressions.Regex("< STYLE >. *< /STYLE >")).Replace(Fields!activitypointer1_description.Value,""),"")

The problem is that the second expression ("< STYLE >. *< /STYLE >" without the spaces) which should be executed first doesn't do anything. The result contains the styles from the html without the tags attached.

I'm out of ideas.

C

A: 

You need to add RegexOptions.Singleline, because by default Regular expressions will stop on newline characters. Here's an example of a console program you can run to verify it:

string decription = @"<b>this is some 
text</b><style>and 
this is style</style>";
        Console.WriteLine(
            (new Regex( "<[^>]*>", RegexOptions.IgnoreCase | RegexOptions.Singleline ))
            .Replace(
                (new Regex( "<STYLE>.*</STYLE>", RegexOptions.IgnoreCase | RegexOptions.Singleline ))
                    .Replace( decription
                    , "" )
            , "" )
         );
DonkeyMaster
the SingleLine Option was the thingy10x
Cosmin