String.ReplaceLineEndings 方法

定義

多載

ReplaceLineEndings(String)

以 取代目前字串 replacementText 中的所有換行序列。

ReplaceLineEndings()

以 取代目前字串 NewLine 中的所有換行序列。

ReplaceLineEndings(String)

Source:
String.Manipulation.cs
Source:
String.Manipulation.cs
Source:
String.Manipulation.cs

以 取代目前字串 replacementText 中的所有換行序列。

public:
 System::String ^ ReplaceLineEndings(System::String ^ replacementText);
public string ReplaceLineEndings (string replacementText);
member this.ReplaceLineEndings : string -> string
Public Function ReplaceLineEndings (replacementText As String) As String

參數

replacementText
String

要做為取代的文字。

傳回

字串,其內容符合目前的字串,但所有換行序列都會取代為 replacementText

備註

這個方法會搜尋字串內的所有換行序列,並將其標準化為 所提供的 replacementText 換行序列。 如果 replacementTextEmpty ,則會移除字串內的所有換行序列。

不建議通訊協定剖析器使用此 API。 通訊協定規格通常會要求特定的換行序列。 例如,HTTP/1.1 (RFC 8615) 會要求行、狀態行和標頭行結尾為 CRLF。 由於此 API 在各種不同的換行序列上運作,因此使用此 API 的通訊協定剖析器可能會呈現通訊協定作者不預期的行為。

辨識的換行序列清單是 CR (U+000D) 、LF (U+000A) 、 CRLF (U+000D U+000A) 、NEL (U+0085) 、LS (U+2028) 、FF (U+000C) ,以及 PS (U+2029) 。 此清單是由 Unicode Standard,Sec. 5.8,Recommendation R4 和 Table 5-2 所提供。

此方法保證 O (n * r) 複雜度,其中 n 是輸入字串的長度,其中 r 是 的 replacementText 長度。

適用於

ReplaceLineEndings()

Source:
String.Manipulation.cs
Source:
String.Manipulation.cs
Source:
String.Manipulation.cs

以 取代目前字串 NewLine 中的所有換行序列。

public:
 System::String ^ ReplaceLineEndings();
public string ReplaceLineEndings ();
member this.ReplaceLineEndings : unit -> string
Public Function ReplaceLineEndings () As String

傳回

字串,其內容符合目前的字串,但所有換行序列都會取代為 NewLine

備註

這個方法會搜尋字串內的所有換行序列,並規範它們以符合目前環境的換行序列。 例如,在 Windows 上執行時,所有出現的非 Windows 換行序列都會取代為序列 CRLF。 在 Unix 上執行時,所有出現的非 Unix 換行序列都會取代為單一 LF 字元。

不建議通訊協定剖析器使用此 API。 通訊協定規格通常會要求特定的換行序列。 例如,HTTP/1.1 (RFC 8615) 會要求行、狀態行和標頭行結尾為 CRLF。 由於此 API 在各種不同的換行序列上運作,因此使用此 API 的通訊協定剖析器可能會呈現通訊協定作者不預期的行為。

這個多載相當於呼叫 ReplaceLineEndings(String) ,傳遞 NewLinereplacementText 參數。

此方法保證 O (n) 複雜度,其中 n 是輸入字串的長度。

適用於