Stop re-expression after double spaces

I am trying to match the contents of a string with double space appearing (ignoring the case where the double space is after the autor / name id) or any other character other than AZ or a single space until the moment I came up with the following regex, although \ S does not match anything other than a space.

(AUTOR|NAME):?([A-Z ]\S)+


AUTOR:  LEANDRO LUCIANI  TAVARES -- This should match up to 'AUTOR:  LEANDRO LUCIANI'

AUTOR LEANDRO LUCIANI \TAVARES -- This should match up to 'AUTOR LEANDRO LUCIANI' discarding anything after the backslash

AUTOR       LEANDRO TAVARES -- This should match up to 'AUTOR       LEANDRO TAVARES'

      

Edit:

I am trying to run it in C # so that it is compatible with the .NET regex implementation.

Thanks in advance, Leandro Tavares

+3


source to share


2 answers


What you are looking for is perhaps something like this:



(AUTOR|NAME)[\s:]\s*([A-Z]+( [A-Z]+)*)

      

+3


source


This PCRE works for me:



/(AUTOR|NAME):?\s*([A-Z ]+?)(?:  | \\|\\|$)/

      

+1


source







All Articles