Regular Expression

  • Thread starter Thread starter Ori
  • Start date Start date
O

Ori

Hi,

Small Question ( i want to know how to do it in general, so i'll give
a short example):

I have the following string:

p_arg_names=_show_header&p_arg_values=YES&p_arg_names=_rowid&p_arg_values=30487&p_arg_names=_alt_rowid&p_arg_values=SEQIDX


How can i extract (using C# & RegEx) the value which assign to
'p_arg_values'?

In general, i would like to know on a good pattern to do such thing
Thanks,

Ori.
 
I commonly use a pair of Split method calls.

assuming the entire string is called QS...

QS.split("&")

would give you an array of 6 strings. The second item (item 1) would
be "p_arg_values=YES". If you dont already know it will be the 2nd
item, you would need to loop through finding the one that starts with
p_arg_values.

Now, on that item, do another split. Assuming you find it in a(1)...

a[1].split("=")[1]

Should give you the value "YES". If you know where the positioning
is...

QS.split("&")[1].split("=")[1]

shoud do it for you. Totally air code, but I cant see why it wouldnt
work :)
 
Back
Top