September 26, 200322 yr Any ideas how to solve this problem? I have a field with a page of text. What i would like to get is a script that searches for a specific word (Cast&Crew) and copys the text between the specific word (Cast&Crew) and a second word that follows sometime after in the text. The in between text then will be entered into the field. Any ideas?? Thanks!
September 26, 200322 yr Hi tmas73, and a second word that follows sometime after in the text. Well, we have the start of our search (Cast&Crew). But you haven't given us an end. If you can tell us how to determine where the end is, we can grab everything inbetween and insert it in a field for you via script. Cheers, LaRetta
September 26, 200322 yr Author The 2 word is (Runtime:) So the idea is to get the text between Cast&Crew and Runtime: and place it into a field.. Thanks La Retta
September 26, 200322 yr LeftWords( Middle( textfield, Position( cast, "(Cast&Crew)", 1, 1 ) + 11, Position( textfield, "(Runtime:)", 1, 1 ) - Position( textfield, "(Cast&Crew)", 1, 1 ) - 11 ), 9999 )
September 26, 200322 yr Author Thank you very much!! I go it to work. I have one more question. I only have (Cast&Crew) and i want following few letters or words after cast&crew?? Thanks for your time!
September 26, 200322 yr Hello tmas73, Middle(TextField, Position(TextField, "Cast&Crew", 1, 1 ) + 11, 3) will give you the first three letters following 'Cast&Crew', and LeftWords(Middle(TextField, Position(TextField, "Cast&Crew", 1, 1 ) + 11, 9999), 3) will give you the first three *words* following 'Cast&Crew'.
September 26, 200322 yr Author Thanks Ray worked out fine. i just wonder if it is possible to include a logical function like for example: Go to Cast&Crews on the page and looks for a word after "CastandCrew". Like the Cast&Crew is a starting point for a second search. Search for "Cast&Crew" -> search from point "Cast&Crew" and look for "USA:R" I'm sorry for my "beginners brain" but I really have problems with those search word logic. Thank you!!
September 28, 200322 yr The following expression: Case(Position(TextField, "USA:R", Position(TextField, "Cast&Crew", 1, 1 ), 1 ), "Yes", "No") ...will return 'yes' if the text 'USA:R' occurs in TextField after the first occurrence of 'Cast&Crew'. And in fact: Position(TextField, "USA:R", Position(TextField, "Cast&Crew", 1, 1 ) will give you the character number where USA:R starts.
September 29, 200322 yr Author Thanks again ray but this time I had no luck!! this is the script i use!! Left(Middle(myText, Position(myText, "USA:", Position(myText, "Certification:", 1, 1), 1) 4, 9999), 5) It works fine with "USA:R" but if there is "USA:PG-13" it will cut off 4 letters to the right. I also cant display 4 to the right because after "PG13 or R" there follows a "/" and some other text. So it would display "R /.." Is there a solution where I have as start point "USA:" and to the right the "/". My field of interest is only the rating for the USA so I'm trying to filter it out from a page of text. Like (Must find Certification subcategory USA: ! "Certification: Australia:M /Finland:K-16 /France:-12 /Norway:16 /Sweden:15 /UK:15 /USA:R /West Germany:16" I hope this all makes sense!! Thomas
September 29, 200322 yr Try this: Middle(MyText, Position(MyText, "USA:", Position(MyText, "Certification:", 1, 1), 1), Position(MyText, "/",Position(MyText, "USA:", Position(MyText, "Certification:", 1, 1), 1), 1) - Position(MyText, "USA:", Position(MyText, "Certification:", 1, 1), 1))
September 29, 200322 yr Try this one.... Middle(text,Position(text, "USA:R", Position(text, "Certification:", 1, 1 ),1),Position(text, "/", Position(text, "USA:R", Position(text, "Certification:", 1, 1 ),1), 1) - Position(text, "USA:R", Position(text, "Certification:", 1, 1 ),1)) or a little smaller Middle(text,Position(text, "USA:R", Position(text, "Certification:", 1, 1 ),1), Position(Right(text, Length(text) - Position(text, "USA:R", Position(text, "Certification:", 1, 1 ),1)), "/", 1, 1))
September 29, 200322 yr Ray, you beat me to this It always takes me a "little" more time than you to put this down At least, I'm now sure it'd work
September 29, 200322 yr Hi Ugo, Your second calc my be a little shorter, but you will find that it will fail if there is a '/' between 'Certification' and 'USA:'. Once you correct for this you'll then find that it is then longer than the previous version.
September 29, 200322 yr Author Woooww guys, I am amazed!! I have no idea how you can get to this result!! IT WORKS all 3 versions. The only small change would be: The result I get is "USA:PG-13" what do i have to do to get rid of "USA:". Deeply grateful! =) Thomas
September 29, 200322 yr The simplest way is probably: Middle(MyText, Position(MyText, "USA:", Position(MyText, "Certification:", 1, 1), 1) + 4, Position(MyText, "/",Position(MyText, "USA:", Position(MyText, "Certification:", 1, 1), 1), 1) - Position(MyText, "USA:", Position(MyText, "Certification:", 1, 1), 1) - 4)
September 29, 200322 yr Well, Assuming : - your goal is to parse a given string within a looping script. - It's not given for sure that this string exists in that record - That in this later case, you want the result to be "Empty" - You want to remove the hyphen also. You may try the following Long calculation, involving 2 global fields for FirstString and SecondString. Choose(not Position(TextField&"/",SecondString, Position(TextField&"/", FirstString, 1, 1 ), 1 ), Trim(Substitute(Middle(TextField&"/",Position(TextField&"/", SecondString, Position(TextField&"/", FirstString, 1,1 ),1),Position(TextField&"/", "/", Position(TextField&"/" ,SecondString,Position(TextField&"/", FirstString, 1, 1 ),1), 1) - Position(TextField&"/",SecondString, Position(TextField&"/", FirstString, 1, 1 ),1)),SecondString& ":","")),"Empty")
September 29, 200322 yr Author Ray, you did it!! Thaks a lot for all the help. Also thanks Ugo and the forum! Thomas
Create an account or sign in to comment