Page 1 of 1

Troubleshooting a resequencing

Posted: Sat Jul 09, 2011 11:33 am
by redcairo
I have files which come en masse with an output for multiple choice questions that looks like:

a. option one c. option three
b. option two d. option four

And I need it to look like

a. option one
b. option two
c. option three
d. option four

I'd gotten tips from reading other posts here and thought it would be easy but I'm screwing this up somehow.

I am using the stacked bar below only because when I use only [^]* which seems to me it ought to say 'and all remaining chars to end of line not counting line break' that just errors. So the chances of a stacked bar being in my content is very very slim (not impossible) and I'm using that because then my regexes that need to do that don't fail. I'd like to know what's correct though.

This fails for not found.

Code: Select all

(^a. [^c. ]*)(c. [^|]*$)\n(^b.[^d. ]*)(d. [^|]*$)\n

\1\n\3\n\2\n\4\n
Would hugely appreciate any advice on how to make this work.

Best,
PJ


edited to add the last stacked bar

Posted: Sat Jul 09, 2011 1:00 pm
by ben_josephs
Use "Posix" regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
Search | Replace... (<F8>):
Find what: _([a-z]\.) [Replace the underscore with a space]
Replace with: \n\1

[X] Regular expression

Replace All

Posted: Sat Jul 09, 2011 1:26 pm
by redcairo
can't find upload-image option, so I'm linking to screenshot

Image

In addition to not finding it, I think this misses the detail that I have to rearrange the items, not just return each option to left margin.

Thanks very much,
PJ[/code]

Posted: Sat Jul 09, 2011 1:42 pm
by redcairo
Oh also, the reason I approached it like I did, is that I can't just put a line break ahead of every letter-period-space as there are many other things in the docs like that which need to be unbothered. The only time I need this to happen is when on the line there is
a-period-space and then later c-period-space, and on the next line,
b-period-space and then later d-period-space,
and I need to capture each of those four strings,
and get them each on one line but rearranged to be in the right sequence.

Posted: Mon Jul 11, 2011 8:38 am
by ben_josephs
You appear to have missed the instruction to Replace the underscore with a space?
Find what: ^(a. .*[^ ]) *\<(c. .*)\n^(b. .*[^ ]) *\<(d. .*)
Replace with: \1\n\3\n\2\n\4

[X] Regular expression

Replace All

Posted: Mon Jul 11, 2011 3:44 pm
by redcairo
Oh -- I totally did! -- I'm so sorry -- yes, now that I do it RIGHT, it works perfectly! You're a genius! Thank you so much!!

Man this will be SO helpful ... !!

PJ