O'Reilly Answers is a community site for sharing knowledge, asking questions, and providing answers that brings together our customers, authors, editors, conference speakers, and Foo (Friends of O'Reilly). More »
There is a variety of software (including the Unix command-line
utility uniq and Windows PowerShell
cmdlet Get-Unique) that can help you remove duplicate lines in a file or
...
If you want to strip a string of characters that aren't valid in Windows filenames use the following regular expression to accompish the task.
Regular expression[\\/:"*?|]+
Reg...
You need to find the last pattern match in a string, but you do not want the overhead of finding all matches in a string and having to move to the last match in the collection of matches.
To execute ...
If you want to check whether a certain string represents a valid IPv4 address in 255.255.255.255 notation, try one of these examples from Regular Expressions Cookbook:
Simple regex to check fo...
If you want to check whether a given piece of text is a URL that is
valid for your purposes, you can try one of the following solutions:
Allow almost any URL:
^(https?|ftp|file)://....
If you want to match numbers that use the comma as the thousand
separator and the dot as the decimal separator, refer to the following examples:
Mandatory integer and fraction:^[0-9]{1,3...
If you want to validate dates in the traditional formats mm/dd/yy,
mm/dd/yyyy, dd/mm/yy, and
dd/mm/yyyy, using a simple regex that simply checks whether
the input looks ...
If you want to instantiate a regular expression object or otherwise compile a regular
expression so you can use it efficiently throughout your
application, try one of t...
Traditional grep tools apply your regular expression to one line of text at a time,
and display the lines matched (or not matched) by the regular
expression. If you hav...
If you want to replace all matches of the regular exp​ression before with the replacement
text after, try one of the following examples:C#You can use the static call when you process on...