久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

Replace 方法 (.NET Framework 類庫(kù) - 簡(jiǎn)體中文)

 ShangShujie 2006-11-07
.NET Framework 類庫(kù)  

Regex.Replace 方法

用指定的替換字符串替換由正則表達(dá)式定義的字符模式的所有匹配項(xiàng)。

重載列表

替換在 Regex 構(gòu)造函數(shù)中指定的正則表達(dá)式所定義的字符模式的所有匹配項(xiàng),。在每個(gè)匹配處均調(diào)用 MatchEvaluator 委托以計(jì)算替換。

受 .NET Framework 精簡(jiǎn)版的支持。

[Visual Basic] Overloads Public Function Replace(String, MatchEvaluator) As String
[C#] public string Replace(string, MatchEvaluator);
[C++] public: String* Replace(String*, MatchEvaluator*);
[JScript] public function Replace(String, MatchEvaluator) : String;

從輸入字符串中的第一個(gè)字符開始,用替換字符串替換指定的正則表達(dá)式模式的所有匹配項(xiàng),。

受 .NET Framework 精簡(jiǎn)版的支持。

[Visual Basic] Overloads Public Function Replace(String, String) As String
[C#] public string Replace(string, string);
[C++] public: String* Replace(String*, String*);
[JScript] public function Replace(String, String) : String;

從輸入字符串中的第一個(gè)字符開始,,用替換字符串替換由 Regex 構(gòu)造函數(shù)中指定的正則表達(dá)式定義的模式的指定數(shù)目的匹配項(xiàng),。在每個(gè)匹配處均調(diào)用 MatchEvaluator 委托以計(jì)算替換。

受 .NET Framework 精簡(jiǎn)版的支持,。

[Visual Basic] Overloads Public Function Replace(String, MatchEvaluator, Integer) As String
[C#] public string Replace(string, MatchEvaluator, int);
[C++] public: String* Replace(String*, MatchEvaluator*, int);
[JScript] public function Replace(String, MatchEvaluator, int) : String;

從輸入字符串中的第一個(gè)字符開始,,用指定的替換字符串替換由 Regex 構(gòu)造函數(shù)中指定的正則表達(dá)式定義的指定數(shù)目的模式匹配項(xiàng)。

受 .NET Framework 精簡(jiǎn)版的支持,。

[Visual Basic] Overloads Public Function Replace(String, String, Integer) As String
[C#] public string Replace(string, string, int);
[C++] public: String* Replace(String*, String*, int);
[JScript] public function Replace(String, String, int) : String;

從第一個(gè)字符開始,,用替換字符串替換由正則表達(dá)式定義的字符模式的所有匹配項(xiàng)。在每個(gè)匹配處均調(diào)用 MatchEvaluator 委托以計(jì)算替換,。

受 .NET Framework 精簡(jiǎn)版的支持,。

[Visual Basic] Overloads Public Shared Function Replace(String, String, MatchEvaluator) As String
[C#] public static string Replace(string, string, MatchEvaluator);
[C++] public: static String* Replace(String*, String*, MatchEvaluator*);
[JScript] public static function Replace(String, String, MatchEvaluator) : String;

從輸入字符串中的第一個(gè)字符開始,,用替換字符串替換由正則表達(dá)式定義的匹配的所有匹配項(xiàng)。

受 .NET Framework 精簡(jiǎn)版的支持,。

[Visual Basic] Overloads Public Shared Function Replace(String, String, String) As String
[C#] public static string Replace(string, string, string);
[C++] public: static String* Replace(String*, String*, String*);
[JScript] public static function Replace(String, String, String) : String;

從輸入字符串中的指定字符位置開始,,用替換字符串替換 Regex 構(gòu)造函數(shù)中指定的模式的指定數(shù)目的匹配項(xiàng)。在每個(gè)匹配處均調(diào)用 MatchEvaluator 委托以計(jì)算替換,。

受 .NET Framework 精簡(jiǎn)版的支持,。

[Visual Basic] Overloads Public Function Replace(String, MatchEvaluator, Integer, Integer) As String
[C#] public string Replace(string, MatchEvaluator, int, int);
[C++] public: String* Replace(String*, MatchEvaluator*, int, int);
[JScript] public function Replace(String, MatchEvaluator, int, int) : String;

從輸入字符串中的指定字符位置開始,用指定的替換字符串替換由 Regex 構(gòu)造函數(shù)中指定的正則表達(dá)式定義的輸入字符串中的模式的指定數(shù)目的匹配項(xiàng),。

受 .NET Framework 精簡(jiǎn)版的支持,。

[Visual Basic] Overloads Public Function Replace(String, String, Integer, Integer) As String
[C#] public string Replace(string, string, int, int);
[C++] public: String* Replace(String*, String*, int, int);
[JScript] public function Replace(String, String, int, int) : String;

從第一個(gè)字符開始,用替換字符串替換由指定正則表達(dá)式定義的字符模式的所有匹配項(xiàng),??梢灾付ㄏ鄳?yīng)選項(xiàng)來修改匹配行為,并且每次匹配都將調(diào)用一個(gè) MatchEvaluator 委托來計(jì)算替換項(xiàng),。

受 .NET Framework 精簡(jiǎn)版的支持。

[Visual Basic] Overloads Public Shared Function Replace(String, String, MatchEvaluator, RegexOptions) As String
[C#] public static string Replace(string, string, MatchEvaluator, RegexOptions);
[C++] public: static String* Replace(String*, String*, MatchEvaluator*, RegexOptions);
[JScript] public static function Replace(String, String, MatchEvaluator, RegexOptions) : String;

從輸入字符串中的第一個(gè)字符開始,,用指定的替換字符串替換由指定的正則表達(dá)式定義的模式的所有匹配項(xiàng),。可指定選項(xiàng)來修改匹配的行為,。

受 .NET Framework 精簡(jiǎn)版的支持,。

[Visual Basic] Overloads Public Shared Function Replace(String, String, String, RegexOptions) As String
[C#] public static string Replace(string, string, string, RegexOptions);
[C++] public: static String* Replace(String*, String*, String*, RegexOptions);
[JScript] public static function Replace(String, String, String, RegexOptions) : String;

示例

[Visual Basic]
Imports System.Text.RegularExpressions
Class RegExSample
Shared Function CapText(m As Match) As String
‘ Get the matched string.
Dim x As String = m.ToString()
‘ If the first char is lower case...
If Char.IsLower(x.Chars(0)) Then
‘ Capitalize it.
Return Char.ToUpper(x.Chars(0)) & x.Substring(1, x.Length - 1)
End If
Return x
End Function
Public Shared Sub Main()
Dim text As String = "four score and seven years ago"
System.Console.WriteLine("text=[" & text & "]")
Dim result As String = Regex.Replace(text, "\w+", _
AddressOf RegExSample.CapText)
System.Console.WriteLine("result=[" & result & "]")
End Sub
End Class
[C#]
using System.Text.RegularExpressions;
class RegExSample
{
static string CapText(Match m)
{
// Get the matched string.
string x = m.ToString();
// If the first char is lower case...
if (char.IsLower(x[0]))
{
// Capitalize it.
return char.ToUpper(x[0]) + x.Substring(1, x.Length-1);
}
return x;
}
static void Main()
{
string text = "four score and seven years ago";
System.Console.WriteLine("text=[" + text + "]");
string result = Regex.Replace(text, @"\w+",
new MatchEvaluator(RegExSample.CapText));
System.Console.WriteLine("result=[" + result + "]");
}
}
[C++]
#using <mscorlib.dll>
#using <System.dll>
using namespace System;
using namespace System::Text::RegularExpressions;
__gc class RegExSample
{
public:
static String* CapText(Match* m)
{
// Get the matched String.
String* x = m->ToString();
// If the first char is lower case...
if (Char::IsLower(x->Chars[0]))
{
// Capitalize it.
return String::Concat(__box(Char::ToUpper(x->Chars[0])), x->Substring(1, x->Length-1));
}
return x;
}
};
int main()
{
String* text = S"four score and seven years ago";
Console::WriteLine(S"text=[{0}]", text);
String* result = Regex::Replace(text, S"\\w+", new MatchEvaluator(0, &RegExSample::CapText));
System::Console::WriteLine(S"result=[{0}]", result);
}
[JScript]
import System.Text.RegularExpressions;
class RegExSample
{
static function CapText(m : Match) : String
{
// get the matched string.
var x : String = m.ToString();
// If the first char is lower case...
if (System.Char.IsLower(x[0]))
{
// Capitalize it.
return System.Char.ToUpper(x[0]) + x.Substring(1, x.Length-1);
}
return x;
}
static function Main() : void
{
var text : String = "four score and seven years ago";
System.Console.WriteLine("text=[" + text + "]");
var result : String = Regex.Replace(text, "\\w+", RegExSample.CapText);
System.Console.WriteLine("result=[" + result + "]");
}
}
RegExSample.Main();

請(qǐng)參見

Regex 類 | Regex 成員 | System.Text.RegularExpressions 命名空間

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點(diǎn),。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,,謹(jǐn)防詐騙,。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào),。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多