1

I'm new here. I was seeking for some help to get the following done with regex.

I have a MC tests lines like this:

Q1  I.......go to see the doctor last week because I was very ill.  
(a) must (b) must to    (c) had to (d) should to
Q2  I could.......bought that car but I didn't have enough money to pay for the petrol. 
(a) had (b) have    (c) have to (d) can

I would like the line from horizontal to vertical. That's it. It should look like this.

Q1  I.......go to see the doctor last week because I was very ill.  
(a) must
(b) must to
(c) had to
(d) should to

Q2  I could.......bought that car but I didn't have enough money to pay for the petrol. 
(a) had
(b) have
(c) have to
(d) can

I can't seem to make it work. That would save me long long hours of work. Any help is appreciated.

5
  • Actually it should look like this: Q1 I.......go to see the doctor last week because I was very ill. (a) must (b) must to (c) had to (d) should to Q2 I could.......bought that car but I didn't have enough money to pay for the petrol. (a) had (b) have (c) have to (d) can Commented Apr 19, 2016 at 6:39
  • Where do you want to apply the regex? Text editor? Program? If so, in which language? Commented Apr 19, 2016 at 6:41
  • I have problem with inserting the text as it should look like. I need this in Notepad ++ Commented Apr 19, 2016 at 6:41
  • Did my edit to your question make it correct? Commented Apr 19, 2016 at 6:42
  • Yes, it looks now correct. It should be vertical not horizontal Commented Apr 19, 2016 at 6:43

1 Answer 1

2

Find:

(\([b-d]\))

* this is for a-d answers, change d for the maximum possible answer

Replace with:

\r\n$1

Input:

Q1  I.......go to see the doctor last week because I was very ill.  
(a) must (b) must to    (c) had to (d) should to
Q2  I could.......bought that car but I didn't have enough money to pay for the petrol. 
(a) had (b) have    (c) have to (d) can

Output:

Q1  I.......go to see the doctor last week because I was very ill.  
(a) must 
(b) must to    
(c) had to 
(d) should to
Q2  I could.......bought that car but I didn't have enough money to pay for the petrol. 
(a) had 
(b) have    
(c) have to 
(d) can

Is this enough?

If you want to separate questions with newlines, you can also search for: ^Q(?!1\b)(\d*)\b and replace with \r\nQ$1. That will insert a newline before all questions except for #1

Sign up to request clarification or add additional context in comments.

8 Comments

[b-z] probably. And then replace ^Q\d with another \r\n$1. :)
@bipll according to his question, there's just [b-d]... I added the Qx on a update, excepting #1 :-)
Perfect! Thank you very much. You saved me a lot of time :) Where shall I send you the beer? :) Thank you again!
Yeah, sure, #1. On 'd' or 'z', the question is formulated in terms of 'like' so I fancy it'll be safer that way. :)
@bipll I added a note ;-)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.