zoukankan      html  css  js  c++  java
  • 分析模板的一段简单快速的算法片段

    char[] templateText = txt.ToCharArray();
                
    //ITemplate it = new CleanTemplate();

                List
    <Tag> tags = new List<Tag>();
                
    char[] temp = new char[100];

                
    for (int i = 0; i < templateText.Length; i++)
                {
                    
    if (templateText[i] == '{')
                    {
                        
    if (i > 0 && templateText[i - 1== '\\')
                            
    continue;

                        Tag tag 
    = new Tag();
                        tag.StartIndex 
    = i;
                        context.Response.Write(templateText[i]);

                        
    while (++< templateText.Length && templateText[i] != '}')
                        {
                            
    if (templateText[i] == ' ')
                            {
                                
    if (isFirstSpace)
                                {
                                    isFirstSpace 
    = false;
                                    context.Response.Write(
    " ");
                                }
                                
    continue;
                            }
                            context.Response.Write(templateText[i]);
                        }
                        tag.EndIndex 
    = i;
                        context.Response.Write(templateText[i]);
                        context.Response.Write(
    "<br />");
                    }

                    isFirstSpace 
    = true;
                }

  • 相关阅读:
    学习数据结构的网站
    线程的自动释放、挂起、运行
    centos7 odbc mysql
    c++和c不同
    Linux挂载u盘作为本地yum源安装gcc
    构建基于JAVASCRIPT的移动WEB CMS入门——简介(转载)
    数据库SQL优化大总结之 百万级数据库优化方案
    webgl 刷底色的基本步骤
    前端下载文件流并且获取heads中的filename文件名且解决中文乱码的方法
    Python little knowledge
  • 原文地址:https://www.cnblogs.com/afxcn/p/763225.html
Copyright © 2011-2022 走看看