Delete Before and After

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

thenquirer
Posts: 3
Joined: Mon Mar 22, 2010 1:41 am

Delete Before and After

Postby thenquirer » Mon Mar 22, 2010 1:46 am

Hello there,

How do i remove anything before a word in a text passage. For example,
What Petraeus said is this: "The [Israeli-Arab] conflict foments anti-American sentiment, due to a perception of U.S. favoritism for Israel. Arab anger over the Palestinian question limits the strength and depth of U.S. partnerships with governments and peoples ? and weakens the legitimacy of moderate regimes in the Arab world. Meanwhile, al-Qaida and other militant groups exploit that anger to mobilize support. The conflict also gives Iran influence in the Arab world through its clients, Lebanese Hizballah and Hamas."
How do i remove anything before the word <"The>.

-Thenq.

User avatar
DataMystic Support
Site Admin
Posts: 2138
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Delete Before and After

Postby DataMystic Support » Mon Mar 22, 2010 10:53 am

Sounds like a troll to me, but use a perl pattern search/replace for:

Code: Select all

^(.*)("The)

Replace with

Code: Select all

$2
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

pakiyabhai
Posts: 8
Joined: Tue Feb 09, 2010 7:26 pm

Re: Delete Before and After

Postby pakiyabhai » Mon Mar 22, 2010 3:31 pm

this didn't work for me.

Did it work for you ? For me it doesn't do anything. I tried using perl search replace only

User avatar
DataMystic Support
Site Admin
Posts: 2138
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Delete Before and After

Postby DataMystic Support » Tue Mar 23, 2010 9:06 am

Works perfectly here - this is the pattern match:

Code: Select all

|--Perl pattern [^(.*)("The)] with [$2]
|     [ ] Match case
|     [ ] Whole words only
|     [ ] Case sensitive replace
|     [X] Prompt on replace
|     [ ] Skip prompt if identical
|     [ ] First only
|     [ ] Extract matches
|     Maximum text buffer size 4096
|     [ ] Maximum match (greedy)
|     [ ] Allow comments
|     [X] '.' matches newline
|     [ ] UTF-8 Support
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

thenquirer
Posts: 3
Joined: Mon Mar 22, 2010 1:41 am

Re: Delete Before and After

Postby thenquirer » Tue Mar 23, 2010 9:29 am

Hi,

Can i know why the replacement is $2 instead of $1? If additional to removing the text infront, i want to remove everything after the text "to mobilize support.", what is the correct syntax and replacement that should be used?

-Thenq.

User avatar
DataMystic Support
Site Admin
Posts: 2138
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Delete Before and After

Postby DataMystic Support » Tue Mar 23, 2010 9:54 am

You could always read the manual...

$1 contains all the text prior to "The

Use EasyPattern search/replace

Code: Select all

to mobilize support.[ longest 1+ not cr or lf ]


Replace with

Code: Select all

to mobilize support.
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

thenquirer
Posts: 3
Joined: Mon Mar 22, 2010 1:41 am

Re: Delete Before and After

Postby thenquirer » Tue Mar 23, 2010 10:20 am

I did but i cant seem to search for symbols in the chm file. Sorry, i'm still trying to get used to it. I've been looking to manipulate data like texts, to remove before and after. Also to add strings if its not present. For example, if i want to add "Report Checked" to the end of the file if it does not exist, is it feasible? Thanks.

-Thenq.

User avatar
DataMystic Support
Site Admin
Posts: 2138
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Delete Before and After

Postby DataMystic Support » Tue Mar 23, 2010 4:18 pm

Yes, search for perl pattern:

Code: Select all

.*?Report Checked.*?


Set Action to: Send non-matching text to subfilter

Then Add an Add Footer filter as a subfilter, with text of

Code: Select all

Report Checked
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments


Return to “TextPipe Tips and Tricks, Questions and Support”

Who is online

Users browsing this forum: No registered users and 1 guest