Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
salman23
Level 7

paragraph not splitting as sentences..

Hi,
i am using roRegex component for splitting the description paragraph into strings by using ". " as the delimiter.But i am getting a weird output.Can somebody help please..?

code:
if valid(videodesc)
SplitDesc = CreateObject("roRegex",". ", "")
if SplitDesc.IsMatch(videodesc)
FinalDesc =""
print "contains :";regex
print "description: ";videodesc
descCase = SplitDesc.split(videodesc)
print "no of sentences :";descCase.Count()
for each descript in descCase
print "each sentence :";descript
' FinalDesc = FinalDesc + descript
end for
' videodesc = FinalDesc


else
print "no matching expression found.."
end if


output:

description: The full feature documentary of Indie Game: The Movie with clean audio and visuals. Audio swears omitted and potentially offending images and swear
s on screen blurred. The Super Clean version is also available in a handy, gift-able DVD form: http://shop.indiegamethemovie.com/produ ... -the-movie

no of sentences : 40
each sentence :Th
each sentence :ful
each sentence :featur
each sentence :documentar
each sentence Smiley Surprised
each sentence :Indi
each sentence :Game
each sentence :Th
each sentence :Movi
each sentence :wit
each sentence :clea
each sentence :audi
each sentence :an
each sentence :visuals
each sentence :Audi
each sentence :swear
each sentence Smiley Surprisedmitte
each sentence :an
each sentence Smiley Tongueotentiall
each sentence Smiley Surprisedffendin
each sentence :image
each sentence :an
each sentence :swear
each sentence Smiley Surprised
each sentence :scree
each sentence :blurred
each sentence :Th
each sentence Smiley Frustratedupe
each sentence :Clea
each sentence :versio
each sentence :i
each sentence :als
each sentence :availabl
each sentence :i
each sentence :
each sentence :handy
each sentence :gift-abl
each sentence Smiley Very HappyV
each sentence :form
0 Kudos
2 Replies
renojim
Level 8

Re: paragraph not splitting as sentences..

In a regular expression, . matches any character. You need to escape the period. I think you want (untestedSmiley Happy
SplitDesc = CreateObject("roRegex","\. ", "")

You may want to look into the Tokenize function:
lines = videodesc.tokenize(".")
for each line in lines
print line.trim()
end for


-JT
0 Kudos
salman23
Level 7

Re: paragraph not splitting as sentences..

"renojim" wrote:
In a regular expression, . matches any character. You need to escape the period. I think you want (untestedSmiley Happy
SplitDesc = CreateObject("roRegex","\. ", "")

You may want to look into the Tokenize function:
lines = videodesc.tokenize(".")
for each line in lines
print line.trim()
end for


-JT



It was a great information, Renojim. Thanks a bunch.
0 Kudos