ibobo Posted March 9, 2016 Share Posted March 9, 2016 (edited) 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 March 9, 2016 by ibobo Link to comment Share on other sites More sharing options...
comment Posted March 9, 2016 Share Posted March 9, 2016 (edited) 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 March 9, 2016 by comment Link to comment Share on other sites More sharing options...
ibobo Posted March 9, 2016 Author Share Posted March 9, 2016 Thanks you a lot Comment ! it works perfectly last think if i want add to Romeo many other strings like Juliet, Freud, ..? Link to comment Share on other sites More sharing options...
comment Posted March 9, 2016 Share Posted March 9, 2016 3 minutes ago, ibobo said: if i want add to Romeo many other strings like Juliet, Freud, How many? And where do you want to keep them? Link to comment Share on other sites More sharing options...
ibobo Posted March 9, 2016 Author Share Posted March 9, 2016 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 More sharing options...
comment Posted March 9, 2016 Share Posted March 9, 2016 57 minutes ago, ibobo said: maybe if i put them in a field with different table That would seem most suitable. See the attached: Loop2.fp7 1 Link to comment Share on other sites More sharing options...
ibobo Posted March 9, 2016 Author Share Posted March 9, 2016 thanks you ! it s work perfectly, like in my dream Link to comment Share on other sites More sharing options...
ibobo Posted March 14, 2016 Author Share Posted March 14, 2016 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 More sharing options...
comment Posted March 14, 2016 Share Posted March 14, 2016 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 More sharing options...
ibobo Posted March 14, 2016 Author Share Posted March 14, 2016 merci beaucoup ! works perfectly you are genius ! Link to comment Share on other sites More sharing options...
Recommended Posts
This topic is 3093 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 accountSign in
Already have an account? Sign in here.
Sign In Now