Forum Moderators: open
However I'm trying to replace ... with … because the validator threw this up as an character not recognised
when I try to replace it within the function using:
str=replace(str, "...", "…")
it's not detecting it, function is working fine with everything else
... is being used quite a lot in the "teaser" heading leading to the full document, sometimes no space between the last character before the leader, sometimes there is...
any ideas?
Suzy
and I want it to search for three periods because that is what is being entered by the user into the database
btw it is displaying correctly, at least in my browsers, but it's just the various validators are picking it up as being incorrect..so if I searched on your character chameleon, would that not replace other "faulty" characters too? See example code below...
OK now I've got another problem too..and that is how to check for a null string:
here's a shortened version of my function, I've tried using
IF str="" THEN
db_replace_text=""
exit function
END IF
but am really not sure about the correct syntax..any help I'm about all googled out!
example function:
function db_text_replace(str)
str=replace(str, "&", "&")
str=replace(str, "'", "'")
str=replace(str, """", """)
str=replace(str, "...", "…") 'this is not working
str=replace(str, vbcrlf, "<br />" & vbcrlf)
db_text_replace=str
end function
then calling function example
article = db_text_replace(objRS("articletext"))
can I check for a null, within the function without adding the check to each variable
Suzy
[edit] grammar [/edit]
Make your call like this:
article = db_text_replace(objRS("articletext") & "")
What this does is concatenate an empty string onto the null value, changing it from the flaky and unstable null to a upstanding and well-behaved empty string.
instead of:
Make your call like this:
article = db_text_replace(objRS("articletext") & "")
My suggestion:
put this in the first line of the function itself
str="" & str
then carry on as per
...etc...str=replace(str, "&", "&")
I think this does the same thing as you're saying, but you don't need to remember to put that extra bit in the call to function so the call can remain:
article=db_text_replace(objRS("articletext"))
or whatever it is you want to replace...Which would be really useful when I want to use this piece of code again....
Thanks for help
Suzy
(although the ... replace still isn't working I'll live with it!)
One more question..is it possible for a function to be too long? or I've added the following into the replace function above to allow non-html users to input links into their text
str=replace(str, "[url]", "<a target=""_blank"" href=""")
str=replace(str, "[/url]", """>")
str=replace(str, "[link]", "")
str=replace(str, "[/link]", "</a>")
My test server is replacing it correctly but when I uploaded it's not doing this bit.. but it is doing the rest?
is there an error in this that my PWS is being lenient with?
Suzy
[added]
on further investigation, only some of the replaces are working online... mystified
anyone know a better way to write this type of function
any advice appreciated
[/added]
I don't know where I was going wrong, I stripped the function and added things in again one by one, only this time I discovered how to do the "character" search properly (Thanks Chameleon, I understand now;)). I was quoting them like text oops! so now I've fixed the ... dot leader problem too :)
I also changed the replace [url] [link] etc... and used the characters for the brackets in the search...It now seems to be working perfectly so I can use this function against anything pulled from the database, and I can just add things into the function as and when the validator throws up any errors..not normally so picky but this is a special case site
I'm happy, thanks to all who got me pointed in the right direction!
Suzy
:)