You are here: PSPad forum > English discussion forum > Delete a line until find the first point if found
Posted by: Esgrimidor | Date: 2017-02-11 17:41 | IP: IP Logged
I have a file with many lines and phrases.
Example of a line :
This is a line. This line have two phrases. Not have three.
Another line
This is the second line. Never give up.
I would like a script or search with regular expressions to replace the above lines with
This line have two phrases
Never give up
How can i do that ?
Best Regards
--
Nice program indeed
Posted by: vbr | Date: 2017-02-11 20:35 | IP: IP Logged
Esgrimidor:I have a file with many lines and phrases.Example of a line :
This is a line. This line have two phrases. Not have three.
Another line
This is the second line. Never give up.
I would like a script or search with regular expressions to replace the above lines with
This line have two phrases
Never give upHow can i do that ?
Best Regards
Hi,
it seems, that something like the following regex replacement could work for you:
^([^.]*\.\s+)([^.]*)\..*
replace with:
$2
[x] Regular expressions
Make sure to check the ouput on your text sources - surprise is always possible with regexes, if various cornercases are not chechked for carefully.
hth,
vbr
Posted by: Andreas | Date: 2017-02-12 17:37 | IP: IP Logged
You also can try this one:
^.*?\.\s*(.*?\.).*$|^.*$
Replace with:
$1
Explanation:
^ - start of string
$ - end of string
. - any single character
\s - any whitespace character
\. - period "."
* - zero or more
*? - zero or more ungreedy (lazy)
| - OR
Posted by: Esgrimidor | Date: 2017-02-14 22:16 | IP: IP Logged
The scripts are functional and goes well.
After try I need this .
A script able to :
1. expand in the txt file each line discomposed by the point.
Example :
Until the first point. Phrase 2.Phrase 3. Phrase 4. Phrase 5.
"Until the first point" is deleted
And the original line now are four lines in the txt file :
Phrase 2
Phrase 3
Phrase 4
Phrase 5
and so on with the rest of lines of the original txt file.
One limit may be discompose the line in a maximum of 10 phrases . If are more then are not divided and mantain as the rest of line.
I don't know is pspad can do this. If not you can tell me another script able to do this with AutoIt or Autohotkey.
Best Regards
--
Nice program indeed
Posted by: Andreas | Date: 2017-02-14 23:36 | IP: IP Logged
Look here e.g. regex101.com (https:// regex101.com/r/8v3tCH/1)
But I see you are showing some links to your(?) websites made with wordpress. Then you should not do such complicated things in PSPad. You can use PHP which is much easier. E.g. you can split a string first, then trim etc. Or try JS which also is mighty and can split, trim etc.
If you know wordpress do you also know Contao? contao.org I'm working with this CMS (try version 3.5.x not 4.x).
Posted by: Esgrimidor | Date: 2017-02-16 21:47 | IP: IP Logged
Andreas:Look here e.g. regex101.com (https:// regex101.com/r/8v3tCH/1)But I see you are showing some links to your(?) websites made with wordpress. Then you should not do such complicated things in PSPad. You can use PHP which is much easier. E.g. you can split a string first, then trim etc. Or try JS which also is mighty and can split, trim etc.
If you know wordpress do you also know Contao? contao.org I'm working with this CMS (try version 3.5.x not 4.x).
Understood. Only say that I am not that clever one in wordpress. I go some months ago to a wordpress.org meeting.
But I am using wordpress.com and know nothing about PHP.
I will take a look to the links.
Best Regards
--
Nice program indeed
Posted by: Andreas | Date: 2017-02-17 00:10 | IP: IP Logged
Here is a nice tutorial for PHP (http://) tut.php-quake.net. PHP also has a nice docu. Here you can see e.g. what you can do with strings (http://) php.net (/manual/en/ref.strings.php).
Posted by: Esgrimidor | Date: 2017-02-18 00:26 | IP: IP Logged
\s*([^\.]*?\.)
\1\n
Why don't go with pspad ?
--
Nice program indeed
Editor PSPad - freeware editor, © 2001 - 2024 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR