regex/HTMLText question

zryip theSlug zryip.theslug at gmail.com
Wed Dec 16 17:17:21 EST 2009


Okay, I'm back with the end of maybe a full solution.

To enclose a word without its punctuation you have to define also a list of
substitute strings like this :
-> the list of possible form
" <w> ","<w>,","<w>.",".<w>",".<w>."
-> the substitute list
" <box><w><box>
","<box><w><box>,","<box><w><box>.",".<box><w><box>",".<box><w><box>."

With this approach you'll be able to keep your punctuation alive. I'm sure
it'll thank us 8)

To create a list of possible form of whole word, you could:
1) Define the list of punctuation which could starts a word
i.e. : colon,space,nothing,comma ....
2) Define the list of punctuation which could ends a word
i.e. : -,colon,dot,comma ...
3) Then mix all possibilities by two imbricated loops (okay it's like
cooking i'm presume 8))

So you'll obtain something like that :
put "colon,space,comma,nothing,quote" into startCharsList
put "colon,dot,comma,-" into endCharsList

put "<w>" into keyWord
put "<box>" into htmlTag
put "" into wholeWordList
put "" into substituteList

-- Create the list of whole words and its substitute list
repeat with startCharNum = 1 to number of items of startCharsList
repeat with endCharNum = 1 to number of items of endCharsList
put item startCharNum of startCharsList & keyWord & item endCharNum of
endCharsList&"," after wholeWordList
put item startCharNum of startCharsList & htmlTag & keyWord & htmlTag & item
endCharNum of endCharsList&"," after substituteList
end repeat
end repeat

-- Search and boxed one or a list of words
repeat with aWord in wordList
    repeat with wholeWordForm in wholeWordList
        put replaceText(aRegex,"<w>",aWord) into wholeWordForm -- replace
the "<w>" key in your pattern by the word that you need
        get fld "yourField"
        replace wholeWordForm with itSubstituteForm in it
    end repeat
end repeat

See how it could work ?
However not sure of the time of processing...

Give it a try and keep up informed ;)


-Zryip TheSlug- wish you the best ! 8)



More information about the Use-livecode mailing list