Regex: opcional-ignorar comillas dobles

Hello I have a question about matching groups based on the following regular expression

static string partPattern = @"^(?<Key>\w+)\s*(?<Value>.*)$";

Sample Data as following:

        REPLICATE_ID            1986
        ASSAY_NUMBER            877
        ASSAY_VERSION           4
        ASSAY_STATUS            "Research"

I am able to retrieve values correctly and if values are NULL, it works correctly as well. What I am trying to do is to also retrieve a value for instance the last one module which is in double quotes. I am not really sure if i am doing it correctly, would this be the correct regex for the above scenario, I just added quotes before w. Please correct, thanks

  static string partPattern = @"^(?<Key>\"w+)\s*(?<Value>.*)$";

preguntado el 06 de septiembre de 12 a las 15:09

Doesn't your original expression already match such values? -

You want quotes stripped from value? -

@Qtax, You are right it works, the existing regex works too, i just didnt have the node in it ,thanks!!! -

2 Respuestas

You regex is not correct.Atleast for the input you have provided..

If I have understood your question,this is the regex that you need.


funcionaría con multiline modo...

Respondido el 06 de Septiembre de 12 a las 16:09

Not sure where your problem is. This works for me:


Respondido el 06 de Septiembre de 12 a las 16:09

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.