Anonymous user
Strip a set of characters from a string: Difference between revisions
Strip a set of characters from a string (view source)
Revision as of 17:39, 27 July 2011
, 12 years ago→{{header|C sharp}}: added usings and regex
(added c#) |
(→{{header|C sharp}}: added usings and regex) |
||
Line 120:
=={{header|C sharp}}==
<lang C sharp>
using System;
public static string RemoveCharactersFromString(string testString, string removeChars)
{
Line 134 ⟶ 136:
}
</lang>
Usage:
<lang C sharp>
using System;
class Program
{
Line 148 ⟶ 153:
Output:
<pre>Sh ws soul strppr. Sh took my hrt!</pre>
Using Regex:
<lang C sharp>
using System;
using System.Text.RegularExpressions;
private static string RegexRemoveCharactersFromString(string testString, string removeChars)
{
string pattern = "[" + removeChars + "]";
return Regex.Replace(testString, pattern, "");
}</lang>
=={{header|Common Lisp}}==
|