ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Finished Programs

Finished Coding Snack: Separate .txt file at any specified punctuation mark

(1/8) > >>

Quidnunc:
I need to be able to separate text at any specified punctuation mark onto it's own line and then insert a blank line between it and the next separation.  If this can be done simply (I only use a computer, I have no idea of how they do what they do).  I assume this can be done via something like the find & replace box.  I would be happy to make a decent donation if anyone can devise a way of doing this (and tell me how to use it).

Quidnunc  

rjbull:
Could you give a before-and-after example of what you mean, with dummy text if necessary?

skwire:
Also, which text editor are you using?

AbteriX:
You can do that by regular expression f.ex.

FROM:
I need to be able to separate text at any specified punctuation mark onto it's own line and then insert a blank line between it and the next separation.  If this can be done simply (I only use a computer, I have no idea of how they do what they do).  I assume this can be done via something like the find & replace box.  I would be happy to make a decent donation if anyone can devise a way of doing this (and tell me how to use it).-Quidnunc (November 24, 2011, 01:09 PM)
--- End quote ---

TO:
I need to be able to separate text at any specified punctuation mark onto it's own line and then insert a blank line between it and the next separation.
If this can be done simply (I only use a computer,
I have no idea of how they do what they do).
I assume this can be done via something like the find & replace box.
I would be happy to make a decent donation if anyone can devise a way of doing this (and tell me how to use it)

--- End quote ---

USE:
[X] Regular Expression

Search for: (.+?)(\.|,)\s*

With EmEditor replace with \1\2\n
With HippoEDIT replace with $1$2\n


Explanation:
(.+?) means: search one-or-more of any sign, non-greedy, and store that in group no. 1
(\.|,) means: search an literal dot "\."  OR an coma, and store that in group no. 2
\s* means: match none-or-more space(s), we don't store that match but drop them (if any)

Then we replace with what is in group 1 by using \1 or $1, that's the matched sentence.
Then we replace with what is in group 2 by using  \2 or $2, that's the matched punctuation mark.
Then we add an line break or two by using \n

Please note that this may not work like that with all editors. The regex implementation is slightly different between different editors.


To get what you want:
I need to be able to separate text at any specified punctuation mark onto it's own line and then insert a blank line between it and the next separation.

If this can be done simply (I only use a computer,

I have no idea of how they do what they do).

I assume this can be done via something like the find & replace box.

I would be happy to make a decent donation if anyone can devise a way of doing this (and tell me how to use it)


--- End quote ---

just USE two '\n'




HTH?  :D

Quidnunc:
Hi
Thanks for the replies.
Abterix: You have suggested using Regular Expressions, however, I only have the vaguest idea as to what a regular expression is and how it works. To use it I would guess I would have to have some software installed (you mention EmEditor & HippoEDIT which no doubt I would have to buy and learn how to use).

RJBull: Here is an example.
Before
A breeze ruffled the neat hedges of Privet Drive, which lay silent and tidy under the inky sky, the very last place you would expect astonishing things to happen. Harry Potter rolled over inside his blankets without waking up. One small hand closed on the letter beside him and he slept on, not knowing he was special, not knowing he was famous, not knowing he would be woken in a few hours' time by Mrs Dursley's scream as she opened the front door to put out the milk bottles, nor that he would spend the next few weeks being prodded and pinched by his cousin Dudley ...He couldn't know that at this very moment, people meeting in secret all over the country were holding up their glasses and saying in hushed voices: To Harry Potter - the boy who lived!'

After
A breeze ruffled the neat hedges of Privet Drive, which lay silent and tidy under the inky sky, the very last place you would expect astonishing things to happen.
 
Harry Potter rolled over inside his blankets without waking up.

I might, on occasion, also need to chop this next long sentence into meaningful grammatical units at each comma.
 
One small hand closed on the letter beside him and he slept on, not knowing he was special, not knowing he was famous, not knowing he would be woken in a few hours' time by Mrs Dursley's scream as she opened the front door to put out the milk bottles, nor that he would spend the next few weeks being prodded and pinched by his cousin Dudley ...
He couldn't know that at this very moment, people meeting in secret all over the country were holding up their glasses and saying in hushed voices: To Harry Potter - the boy who lived!'

I hope that explains what I want to do.

Skywire: At the moment I use a concordancer, I also use an online text analyser for counting #sentences and other statistical info and (from this website) a line numberer all of which are very useful. Before I use these tools I would like to prepare the text by splitting into individual sentences (or clauses) each on its own line and, if at all possible, to number them.



Navigation

[0] Message Index

[#] Next page

Go to full version