apiladores!
He estado tratando de resolver esto durante algún tiempo, pero sin suerte.
(.*?(?:\.|\?|!))(?: |$)
el patrón anterior captura y divide todas las oraciones en un párrafo con puntuación final.
ejemplo
El partido vuelve con tres
Match { 1. Today is the greatest. You are the greatest. }Sin embargo, estoy tratando de que no se rompa cuando hay un número con un punto y me gustaría ver la siguiente coincidencia en su lugar:
Match { 1.Today is the greatest. You are the greatest. }gracias por tu ayuda de antemano
Usar
.*?[.?!](?=(?<!\d\.)\s+|\s*$)Ver prueba de expresiones regulares .
EXPLICACIÓN
-------------------------------------------------------------------------------- .*? any character except \n (0 or more times (matching the least amount possible)) -------------------------------------------------------------------------------- [.?!] any character of: '.', '?', '!' -------------------------------------------------------------------------------- (?= look ahead to see if there is: -------------------------------------------------------------------------------- (?<! look behind to see if there is not: -------------------------------------------------------------------------------- \d digits (0-9) -------------------------------------------------------------------------------- \. '.' -------------------------------------------------------------------------------- ) end of look-behind -------------------------------------------------------------------------------- \s+ whitespace (\n, \r, \t, \f, and " ") (1 or more times (matching the most amount possible)) -------------------------------------------------------------------------------- | OR -------------------------------------------------------------------------------- \s* whitespace (\n, \r, \t, \f, and " ") (0 or more times (matching the most amount possible)) -------------------------------------------------------------------------------- $ before an optional \n, and the end of the string -------------------------------------------------------------------------------- ) end of look-ahead