Lollipop   

Welcome to PcCare.com

Regular Expressions

Regular Expression Tool

 

Lots of C# Regular Expressions

 

//This example demonstrates the use of named backreferences within the replacement pattern for Regex.Replace. Here, the replacement expression ${day} inserts the substring captured by the group (?<day>…).
//
//The Regex.Replace function is one of several static functions that enable you to use regular expression operations without creating an explicit regular expression object. This is convenient when you do not want to keep the compiled regular expression.
// msdn library


String MDYToDMY(String input)
   {
      return Regex.Replace(input,
         "\\b(?<month>\\d{1,2})/(?<day>\\d{1,2})/(?<year>\\d{2,4})\\b",
         "${day}-${month}-${year}");
   }

 

 

//This code extracts the file extension from a filename and displays it //using asp.net

 

<%# Regex.Replace(DataBinder.Eval(Container.DataItem,
"SourceFileName").ToString(), "(?<file>.+[.]+)+(?<ext>.+)+", "${ext}")%>

 

 

// Remove all characters after the full path (arguments

// c:\windows\test.exe -startup -> c:\windows\test.exe

 

public static string Arguments(string fullpath)

{

Match m11 = Regex.Match(fullpath, ".*[.]exe");

return (m11.Value);

}

 

// Remove quote characters from string

// "c:\windows\test.exe -startup"  -> c:\windows\test.exe -startup

 

 

public static string RemoveQuotes(string fullpath)

{

return(fullpath.Replace("\"",""));

}

 

DISCLAIMER: It is assumed that users are familiar with the operating system they are using and comfortable with making the suggested changes. PcCare.com will not be held responsible if changes you make cause a system failure.

Please review our Terms of Service and Privacy statement before initiating service or using this site. Microsoft® and the Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. PcCare Site Map. About Us

PcCare.com is owned and operated by TechnoChill Inc.