How to Extract String after “?” character using regex?



I have a question and answer like this. The answer is in the next line. How can i extract the answer using Regex ?

What is your name ?
John Doe

Regards Sukumar


Hi @kiran_kumar_sukumar,

I have attached a xaml file for ur reference :slight_smile:

1.> 1st try to some how get the data which includes both the question and answers line.

-Get Text would work fine .

  • Hot key combination would also work fine.

2.> Store in a string variable.
3.> Split - o/p will be an array .
4.> Display array element

Cheers :wink:

Main.xaml (8.5 KB)

Warm Regards,
Prashant Singh

Split the string, following the rule given below:

Rather using regex, You can do this:

  1. Split the on Environment.NewLine and store in array.
  2. For each value in array(array_name) search for the question.
  3. if true, get array index of current element .
    int index = Array.IndexOf(array_name, value)
    string next_element = array_name[next_element]

next_element will contain your answer.


if you want you use regex then use this:

\?(.*) your will get your string in first group

regex.Match(“String after ? character using regex”, “?(.*)”).Groups(1).ToString