i have a script that looks at pages html source code and all i want to do is get a small area of text.
I only included a small fragment of the pages source code. i want all the text between “features of this song ” and “These are just a few of the”. any ideas?
i actualy fixed this with help from the text manipulation topics but now i cant get my result text to become a single line. this is the result but i want it all on the same line.
Your string has lots of extra spaces otherwise it would be easier! Normally a simple find/replace function finding return characters and replacing them with a space would have worked. However, with your string try this approach…
set textList to paragraphs of "
danceable beats,
an ambient intro,
buildup/breakdown,
use of modal harmonies,
the use of chordal patterning,
dry snare,
a tight kick sound,
inventive synth arrangements,
acoustic drum samples,
an electric bass riff,
gritty electric guitar riffs,
subtle use of arpeggiated synths,
affected synths,
ambient synth textures,
dominant use of riffs,
,
"
set oneLine to ""
repeat with i from 1 to count of textList
if (item i of textList) is not "" then
set oneLine to oneLine & removeLeadingAndTrailingSpaces(item i of textList) & space
end if
end repeat
set oneLine to text 1 thru -2 of oneLine
on removeLeadingAndTrailingSpaces(theString)
repeat while theString begins with space
if (count of theString) is greater than 1 then
set theString to text 2 thru -1 of theString
else
exit repeat
end if
end repeat
repeat while theString ends with space
if (count of theString) is greater than 1 then
set theString to text 1 thru -2 of theString
else
exit repeat
end if
end repeat
return theString
end removeLeadingAndTrailingSpaces
thanks that put them all in the same line but it was still spread out with tabs like thins:
So i added the script below and it works perfectly.
set text item delimiters to ditd
set ditd to text item delimiters
set text item delimiters to " "
set textItems to text items of step6
set text item delimiters to ""
if (class of step6 is string) then
set res1 to textItems as string
else -- if (class of TheString is Unicode text) then
set res1 to textItems as Unicode text
end if
set text item delimiters to ditd
return res1