How to replace   to space?

前端 未结 6 1077
青春惊慌失措
青春惊慌失措 2020-12-03 21:44

Content is

    Hello World.

hello World


        
相关标签:
6条回答
  • 2020-12-03 22:02

    This will find you all those strips of the text containing &nbsp:

    <[^>]+?&nbsp;[^<]+?>
    

    Fropm here you can just do a simple string replaces with the space since Regex will give you the lcoation ofthe match in your text.

    0 讨论(0)
  • 2020-12-03 22:04
    string A = HttpContext.Current.Server.HtmlDecode(Text);
    
    string A = Text.Replace("&nbsp"," ");
    
    string A = Text.Replace("&amp;nbsp;", " ");
    
                               ↑ &amp;nbsp;
    
    0 讨论(0)
  • 2020-12-03 22:09

    It's simple

    youString.Replace("&nbsp;", " ");
    

    String class http://msdn.microsoft.com/en-us/library/system.string.aspx

    Replace method http://msdn.microsoft.com/en-us/library/fk49wtc1.aspx

    0 讨论(0)
  • 2020-12-03 22:11

    For me the best is :

    Imports System.Web
    HttpUtility.HtmlDecode(codeHtml)
    
    0 讨论(0)
  • 2020-12-03 22:13

    Can you try searching for

    (?<=<[^>]*)&nbsp;
    

    and replacing it with a single space?

    This looks for &nbsp; inside tags (preceded by a < and possibly other characters except >).

    This is extremely brittle, though. For example, it will fail if you have </> symbols in strings/attributes. Better avoid getting those &nbsp; into the wrong locations in the first place.

    0 讨论(0)
  • 2020-12-03 22:15

    just Replace &nbsp to string.Empty after Text Like Below..

    xyz.Text.Replace("&nbsp;", string.Empty);

    0 讨论(0)
提交回复
热议问题