Jump to content

Remove Sentence if contain a string


This topic is 2955 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hello, i try to delete a paragraph or sentence if it contains a sting for example

Quote

The prologue of Romeo and Juliet calls the title characters “star-crossed lovers”

And the stars do seem to conspire against these young lovers

 

Romeo is a Montague, and Juliet a Capulet

Their families are enmeshed in a feud, but the moment they meet

when Romeo and his friends attend a party at Juliet’s house in disguise

he two fall in love and quickly decide that they want to be married

in this field i would like to delete all sentence containing string "romeo"  so the result should be : 

Quote

And the stars do seem to conspire against these young lovers

 

Their families are enmeshed in a feud, but the moment they meet

 

he two fall in love and quickly decide that they want to be married

Thanks you :) 

Edited by ibobo
Link to comment
Share on other sites

44 minutes ago, ibobo said:

i try to delete a paragraph or sentence if it contains a sting

There is a big difference between a paragraph and a sentence. Filemaker knows what a paragraph is (technically, it's a value in a return-separated list), but it has no concept of a sentence.

To remove values containing a string, make your script loop over them and return only those that do not, for example:

Set Variable [ $text; Value:Table::Source ] 
Loop 
  Set Variable [ $i; Value:$i + 1 ] 
  Exit Loop If [ $i > ValueCount ( $text ) ] 
  Set Variable [ $para; Value:MiddleValues ( $text ; $i ; 1 ) ] 
  If [ not PatternCount ( $para ; "romeo" ) ] 
    Set Variable [ $result; Value:$result & $para ] 
  End If 
End Loop 
Set Field [ Table::Target; $result ] 

 

 

 

 

Edited by comment
Link to comment
Share on other sites

a lot, like 100 -/+, and keep where it s the best ? 

maybe if i put them in a field with different table and PatternCount take it each and loop ?  

 

 

Link to comment
Share on other sites

Hi Comment,

do you know  if i could add that the script that you made : delete also previous paragraph ? 

for exemple : 

Quote

And the stars do seem to conspire against these young lovers

 

Their families are enmeshed in a feud, but the moment they meet

he two fall in love and quickly decide that they want to be married 

if content "two" delete the same paragraph and the previous paragraph. like this : 

 

Quote

And the stars do seem to conspire against these young livers

 

(deleted because previous to "two"

(deleted because of content "two"

Thanks 

Link to comment
Share on other sites

I believe it would be easier to discard a paragraph when it or the next paragraph contain the search string.

To do this, you can change the definition of the $match variable to =

PatternCount ( MiddleValues ( $text ; $i ; 2 ) ; GetValue ( $values ; $j ) )

 

 

 

 

Link to comment
Share on other sites

This topic is 2955 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.