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;
                }

  • 相关阅读:
    《大型网站技术架构》-读书笔记一:大型网站架构演化
    网站性能测试指标及网站压力测试
    PHP生成二维码
    数据结构与算法之PHP实现队列、栈
    数据结构与算法之PHP实现链表类(单链表/双链表/循环链表)
    PHP 堆 栈 数据段 代码段 存储的理解
    堆”,"栈","堆栈","队列"以及它们的区别
    c#加密
    Sequence contains no elements : LINQ error
    asp.net core2.0 连接mysql和mssql
  • 原文地址:https://www.cnblogs.com/afxcn/p/763225.html
Copyright © 2011-2022 走看看