Align Questions in One line.
-
Hi everyone… hope you can help me. Apologies for my English.
I got like 1800 questions. Like this:
As you can see question 295 is in one single line. But question 296 es in two lines. I have a lot of questions like that, like 296. I need all the questions to be in one single line. how can i achieve that?
Thanks.
-
You could use this as a starting point:
Find:
(?-s)^\d+\..+\K\R(?!A\))
Replace: a single space
Search mode: Regular expression -
@Alan-Kilborn said in Align Questions in One line.:
Find: (?-s)^\d+…+\K\R(?!A))
Replace: a single space
Search mode: Regular expressionTHANKS A LOT!!! BIG THANKS!!!
That solved my problem!!!
-
Sorry to bother you again… did you know how to do the same, but for the Answers?
I mean… I have this format:
A) XXXXXXXXX
XXXXXX
B)XXXXXXXX
C)XXXXXXXX
D)XXXXXX
XXXXXXXXI want A and B or whatever answers in the exam to be in 1 line too, like this:
A)XXXXXX
B)XXXXX
C)XXXXXXXXX
D)XXXXXXXX -
@Martin-Martin said in Align Questions in One line.:
did you know how to do the same, but for the Answers?
In the regex that @Alan-Kilborn showed, the
\d+\.
at the beginning means “one or more digits followed by a literal dot character”.For requiring it to be one or more letters then an end-parentheses like your answers are, replace that portion of the regex with a regex that means “one or more uppercase letters followed by a literal parentheses”:
\u+\)
…Further, the
(?!A\))
says “stop the match once you hit a literalA)
” … So the equivalent for the answer would be "stop the match once you hit a different capital(s)-then-paren, and stop if you come acrossANSWER:
->(?!\h+\))(?!ANSWER:)
Those tweaks to the original will work for your new
----
Useful References
-
@PeterJones said in Align Questions in One line.:
(?!\h+))(?!ANSWER:)
Sorry I’m new to this. English is not my mother tongue.
I understood this?:
Find: (?-s)^\u+…+\K\R(?!\h+))(?!ANSWER:))
Replace: a single space
Search mode: Regular expressionObviously I did something wrong because it says Invalid Regular Expression.
I managed to erase some parenthesis but the result was that B options and C options dissapeared or merged in one line… I’m a complete disaster. but i managed to undo actions. Everything is fine, answers are back, but I can’t put them in one line yet.
-
You misunderstood on one (the … wasn’t part of the expression: it wasn’t red), and I had a couple of typos (accidentally said
\h+
instead of\u+
).I guess I should have spelled it all out, and should have tried it before posting.
FIND WHAT:
(?-s)^\u+\).+\K\R(?!\u\))(?!ANSWER)
converts
1. Question 1 A) A1 second line B) two C) three D)four with another line ANSWER 2. question two A) A1 second line B) two C) three D)four with another line ANSWER
to
1. Question 1 A) A1 second line B) two C) three D)four with another line ANSWER 2. question two A) A1 second line B) two C) three D)four with another line ANSWER
And if any of your choices are 3 or more lines long, just re-run the regex until it doesn’t make any more changes.
-
@PeterJones said in Align Questions in One line.:
(?-s)^\u+).+\K\R(?!\u))(?!ANSWER)
I don’t know how to express gratitude on the internet. But BIG THANKS. YOU SAVED ME A LOT OF TIME.
Really. THANK YOU.