Share via


TaskLoggingHelper.ExtractMessageCode(String, String) Method

Definition

Extracts the message code (if any) prefixed to the given message string. Message code prefixes must match the following .NET regular expression in order to be recognized: ^\s*[A-Za-z]+\d+:\s* Thread safe.

public:
 System::String ^ ExtractMessageCode(System::String ^ message, [Runtime::InteropServices::Out] System::String ^ % messageWithoutCodePrefix);
public string ExtractMessageCode (string message, out string messageWithoutCodePrefix);
member this.ExtractMessageCode : string * string -> string
Public Function ExtractMessageCode (message As String, ByRef messageWithoutCodePrefix As String) As String

Parameters

message
String

The message to parse.

messageWithoutCodePrefix
String

The message with the code prefix removed (if any).

Returns

The message code extracted from the prefix, or null if there was no code.

Exceptions

Thrown when message is null.

Examples

If this method is given the full message string MYTASK1001: This is an error message. and it accepts This is an error message. as the value for the messageWithoutCodePrefix parameter, then it returns MYTASK1001.

If this method is given the string "MYTASK1001: This is an error message.", it will return "MYTASK1001" for the message code, and "This is an error message." for the message.

Remarks

Message code prefixes must match the following .NET regular expressions in order to be recognized: ^\s*[A-Za-z]+\d+:\s*.

Applies to