• 分析模板的一段简单快速的算法片段


    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将汉字转换为拼音和得到词语首字母(一)
    json字符串、json对象、数组之间的转换
    nginx配置详解(转)
    layer弹出层效果
    Ajax最详细的参数解析和场景应用
    bootstrap table使用指南
    JS的内置对象
    ThinkPHP导出CSV、Excel
    ThinkPHP的易忽视点小结
    sublime text 删除插件
  • 原文地址:https://www.cnblogs.com/afxcn/p/763225.html
Copyright © 2020-2023  润新知