Base de conocimientosCentro de exámenes
ESEspañol
Elegir idioma13

CKTIS / C#

System.Text.RegularExpressions.Regex: referencia práctica

System.Text.RegularExpressions.Regex: referencia práctica: Regex busca coincidencias según un patrón y opciones del motor de expresiones regulares.

Versión: .NET API; verified against .NET 10 reference surface

Sintaxis

System.Text.RegularExpressions.Regex /* select a documented member or constructor */

Regex busca coincidencias según un patrón y opciones del motor de expresiones regulares.

Úsalo para estructuras de texto bien definidas con timeout en entradas no confiables.

El backtracking catastrófico puede consumir CPU; un patrón no sustituye al parser de una gramática compleja.

Sin coincidencia se obtiene Success=false; un patrón no válido lanza RegexParseException.

El programa completo usa realmente System.Text.RegularExpressions.Regex; su stdout esperado exacto es a#b#.

Ejemplos

using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;

Console.WriteLine(Regex.Replace("a1b2", @"\d", "#"));

Resultado

a#b#

El programa completo usa realmente `System.Text.RegularExpressions.Regex`; su stdout esperado exacto es `a#b#`.

Fuentes