You are here: PSPad forum > English discussion forum > Re: Delete a line until find the first point if found

Re: Delete a line until find the first point if found

#1 Delete a line until find the first point if found

Posted by: Esgrimidor | Date: 02/11/2017 18: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
ingenierostenerife.blogspot.com.es
peritostenerife.wordpress.com

Options: Reply | Quote | Up ^


#2 Re: Delete a line until find the first point if found

Posted by: vbr | Date: 02/11/2017 21: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 up

How 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

Options: Reply | Quote | Up ^


#3 Re: Delete a line until find the first point if found

Posted by: Andreas | Date: 02/12/2017 18: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

Options: Reply | Quote | Up ^


#4 Re: Delete a line until find the first point if found

Posted by: Esgrimidor | Date: 02/14/2017 23: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
ingenierostenerife.blogspot.com.es
peritostenerife.wordpress.com

Options: Reply | Quote | Up ^


#5 Re: Delete a line until find the first point if found

Posted by: Andreas | Date: 02/15/2017 00: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).

Options: Reply | Quote | Up ^


#6 Re: Delete a line until find the first point if found

Posted by: Esgrimidor | Date: 02/16/2017 22: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
ingenierostenerife.blogspot.com.es
peritostenerife.wordpress.com

Options: Reply | Quote | Up ^


#7 Re: Delete a line until find the first point if found

Posted by: Andreas | Date: 02/17/2017 01: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).

Options: Reply | Quote | Up ^


#8 Re: Delete a line until find the first point if found

Posted by: Esgrimidor | Date: 02/18/2017 01:26 | IP: IP Logged

\s*([^\.]*?\.)

\1\n

Why don't go with pspad ?

--
Nice program indeed
ingenierostenerife.blogspot.com.es
peritostenerife.wordpress.com

Options: Reply | Quote | Up ^






Editor PSPad - freeware editor, © 2001 - 2017 Jan Fiala
Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák