ReReplace to insert characters on certain words in a list
Hey-
I have a list of words I want to insert a sting into. Basically, the list of words comes from a ReMatch() that looks for words over 10 characters long then puts a <wbr> with those words every 5 characters. I almost have it but it's not strict enough and will put the <wbr> other places.
Here's the code:
<!--- This looks at the string of words (note) and makes an array out of any word over 10 characters long.--->
<cfset rem = #ReMatch("(?i)[a-z0-9+!@##$%^&*()=/?~_-]{10}", note)# />
<!--- This sets the array to a list --->
<cfset listrem = arrayToList(rem, ",")>
<!--- This looks for the two words in the list (listrem = thisisalongword,anotherlongword) and puts in a <wbr> every 5 characters --->
<cfset notes_wbr = reReplaceNoCase("#note#", "(['thisisalongword,anotherlongword']{5})", "\1<wbr>", "all")>
Here's the original string (#note#):
thisisalongword this is a normal word. But this is going to be anotherlongword 123456789
Here's the replaced string (#notes_wbr#):
thisi<wbr>salon<wbr>gword<wbr> this is a normal word. But this is going<wbr> to be anoth<wb>rerlon<wbr>gword<wbr> 123456789
The problem is the "going<wbr>". I only want the <wbr> within the list that I made, but it's also putting it after "going".
Any help on this would be greatly appreciated.
