当前位置: 首页>>代码示例>>C#>>正文


C# Regex.EndsWith方法代码示例

本文整理汇总了C#中System.Text.RegularExpressions.Regex.EndsWith方法的典型用法代码示例。如果您正苦于以下问题:C# Regex.EndsWith方法的具体用法?C# Regex.EndsWith怎么用?C# Regex.EndsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Text.RegularExpressions.Regex的用法示例。


在下文中一共展示了Regex.EndsWith方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseAdditionalInformation

 protected override void ParseAdditionalInformation()
 {
     string bankName = new Regex(@"/BBK/.*\|?").Match(statementLine).Value;
     if (!string.IsNullOrEmpty(bankName))
     {
         bankName = bankName.Substring(5);
         if (bankName.EndsWith("|"))
         {
             bankName = bankName.Substring(0, bankName.Length - 1);
         }
         int vertical = bankName.IndexOf("|");
         if (-1 < vertical)
         {
             bankName = bankName.Substring(0, vertical);
         }
         bankStatement.CptyBankName = bankName.Trim();
     }
     AddInformation();
     //put tag 86 information to remark
     string[] remarks = statementLine.Split(new string[] { TAG_ADDITIONAL_INFO }, StringSplitOptions.None);
     if (remarks.Length > 1)
     {
         bankStatement.Remark = remarks[1];
     }
 }
开发者ID:keenkid,项目名称:BankReportService,代码行数:25,代码来源:HSBCMT940.cs

示例2: Render


//.........这里部分代码省略.........

                //TODO: get alignment data
            }else if (tt != null){
                throw new Exception("Old style tySh font syntax not implemented, found on layer " + l.Name + ". Use a newer version of Photoshop");
            }else if (foundTxt2){
                throw new Exception("Txt2 text layer info not supported, found on layer " + l.Name + ". Where did you find this file? What version of photoshop?");
            }else{
                throw new Exception("No text layer information found on " + l.Name + "!");
            }

            if (outerGlow != null){
                glowColor = outerGlow.Color;
                glowFlag = outerGlow.Enabled;
                glowWidth = (int)outerGlow.Blur;
                glowOpacity = (double)outerGlow.Opacity / 255.0;
            }

            //Replace text if requested.
            if (replacementText != null) text = replacementText;

            //Fix newlines
            text = text.Replace("\r\n", "\n").Replace("\r", "\n");

            //Do graphics stuff
            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;

            using(GraphicsPath path = new GraphicsPath()){
                FontFamily fontFamily = null;
                StringFormat strformat = null;
                try{
                    FontStyle style = FontStyle.Regular;
                    //Remove MT
                    if (fontName.EndsWith("MT")) fontName = fontName.Substring(0, fontName.Length - 2);
                    //Remove -Bold, -Italic, -BoldItalic
                    if (fontName.EndsWith("-Bold", StringComparison.OrdinalIgnoreCase)) style |= FontStyle.Bold;
                    if (fontName.EndsWith("-Italic", StringComparison.OrdinalIgnoreCase)) style |= FontStyle.Italic;
                    if (fontName.EndsWith("-BoldItalic", StringComparison.OrdinalIgnoreCase)) style |= FontStyle.Bold | FontStyle.Italic;
                    //Remove from fontName
                    fontName = new Regex("\\-(Bold|Italic|BoldItalic)$", RegexOptions.IgnoreCase | RegexOptions.IgnoreCase).Replace(fontName, "");
                    //Remove PS
                    if (fontName.EndsWith("PS")) fontName = fontName.Substring(0, fontName.Length - 2);
                    //Find font family
                    try {
                        fontFamily = new FontFamily(fontName);
                    } catch (ArgumentException ae) {
                        if (IgnoreMissingFonts) {
                            fontFamily = FontFamily.GenericSansSerif;
                        } else throw ae;

                    }
                    if (fauxBold) style |= FontStyle.Bold;
                    if (fauxItalic) style |= FontStyle.Italic;
                    if (underline) style |= FontStyle.Underline;
                    if (strikethrough) style |= FontStyle.Strikeout;

                    strformat = new StringFormat();
                    strformat.LineAlignment = hAlign;
                    strformat.Alignment = vAlign;
                    strformat.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.NoClip;
                    if (!horizontal) strformat.FormatFlags |= StringFormatFlags.DirectionVertical;
                    strformat.Trimming = StringTrimming.None;

                    path.AddString(text, fontFamily,
                        (int)style, (float)(fontSize),rect, strformat);
                }finally{
开发者ID:stukalin,项目名称:ImageResizer,代码行数:67,代码来源:TextLayerRenderer.cs

示例3: EquationsFromParentheses

		public static IEnumerable<string> EquationsFromParentheses(string recipe)
		{
			var equations = new List<string>();
			if (string.IsNullOrWhiteSpace(recipe))
			{
				return equations;
			}

			recipe = "(" + recipe + ")"; // If this is a duplication of effort, we'll silently ignore it later.
			recipe = new Regex(@"\s+").Replace(recipe, string.Empty); // Remove all whitespace.
			recipe = LeveledPreparser(recipe);

			var multiLetterMatch = invalidLetterFinder.Match(recipe);
			if (multiLetterMatch.Success)
			{
				throw new ArgumentException("The gem \"" + multiLetterMatch.Value + "\" must be a single letter. Gem combinations must be expressed as individual components separated with plus signs and brackets, as needed. For example:\nob → o+b\nob+o → (o+b)+o");
			}

			var id = 0;
			foreach (var c in Gem.GemInitializer)
			{
				if (recipe.IndexOf(c) > -1)
				{
					recipe = recipe.Replace(c, id.ToString(CultureInfo.InvariantCulture)[0]);
					equations.Add(string.Format(CultureInfo.InvariantCulture, "{0}={1}", id, c));
					id++;
				}
			}

			if (equations.Count == 0)
			{
				throw new ArgumentException("Recipe did not contain any recognizable gems.");
			}

			// Scan for plus signs within the formula and add gems together appropriately.
			int plus = recipe.IndexOf('+');
			string newNum = (id - 1).ToString(CultureInfo.InvariantCulture);
			while (plus > -1)
			{
				string thisCombine;
				var close = recipe.IndexOf(')', plus);
				if (close >= 0)
				{
					var open = recipe.LastIndexOf('(', close);
					if (open < 0)
					{
						throw new ArgumentException("Bracket mismatch in formula.");
					}

					thisCombine = recipe.Substring(open + 1, close - open - 1);

					string[] combineGems = thisCombine.Split('+');
					if (combineGems.Length != 2)
					{
						throw new ArgumentException("The formula provided contains more than a single plus sign within a pair of brackets or a term that is over-bracketed (e.g., \"((o+o))\"). These are not currently supported.");
					}

					if (combineGems[0].Length == 0 || combineGems[1].Length == 0)
					{
						throw new ArgumentException("Invalid formula part: (" + thisCombine + ")");
					}

					newNum = id.ToString(CultureInfo.InvariantCulture);
					recipe = recipe.Replace("(" + thisCombine + ")", newNum);
					equations.Add(string.Format(CultureInfo.InvariantCulture, "{0}={1}+{2}", id, combineGems[0], combineGems[1]));
				}
				else
				{
					throw new ArgumentException("Bracket mismatch in formula.");
				}

				plus = recipe.IndexOf('+');
				id++;
			}

			while (recipe.StartsWith("(", StringComparison.Ordinal) && recipe.EndsWith(")", StringComparison.Ordinal))
			{
				recipe = recipe.Substring(1, recipe.Length - 2);
			}

			if (recipe != newNum)
			{
				if (recipe.Contains("("))
				{
					throw new ArgumentException("Bracket mismatch in formula.");
				}

				throw new ArgumentException("Invalid recipe.");
			}

			return equations;
		}
开发者ID:Chazn2,项目名称:wGemCombiner,代码行数:92,代码来源:Combiner.cs


注:本文中的System.Text.RegularExpressions.Regex.EndsWith方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。