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

  • 相关阅读:
    Java正则表达式入门
    StringBuffer ,String,StringBuilder的区别
    JAVA的StringBuffer类
    容器vector的使用总结 容器stack(栈)
    c++网络通信(与服务器通信聊天)和c#网络通信
    C#与SQLite数据库
    我的vim配置文件
    在world中批量调整图片的大小
    C#判断文件及文件夹是否存在并创建(C#判断文件夹存在)
    C# Thread类的应用
  • 原文地址:https://www.cnblogs.com/afxcn/p/763225.html
Copyright © 2011-2022 走看看