Troubleshooting a resequencing

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
redcairo
Posts: 39
Joined: Fri May 06, 2011 6:34 am

Troubleshooting a resequencing

Post 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
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post 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
redcairo
Posts: 39
Joined: Fri May 06, 2011 6:34 am

Post 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]
redcairo
Posts: 39
Joined: Fri May 06, 2011 6:34 am

Post 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.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post 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
redcairo
Posts: 39
Joined: Fri May 06, 2011 6:34 am

Post 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
Post Reply