p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

proasp_howto thread: Case sensitivity when using Replace...


Message #1 by "Brandon Brownlee" <highside@u...> on Tue, 21 Mar 2000 04:25:35 -0800
Thanks Rob!

That did the trick, and its replacing the root of words even if they are 
plural and what not. The only problem now is when I am referencing a 
pronoun keyword (one that must be capitalized...) "The Internet" for 
instance, is a pronoun. The replace skips it since its looking for LCase 
terms... and if I change it to TextualCompare it messes the link up... and 
of course, if I force EVERYTHING LCase, then I have no capitals 
whatsoever.

Anyone have any ideas on this?

Thanks again,
Brandon

On 03/21/00, "Robert Chartier" wrote:
> strThis = replace(lcase(strThis),lcase(withThis))

 or use instr, mid, etc.. to find and replace the position with the new 
text


as for your plurals, store the root word and no the alternatives.  Then 
when you're replaceing ensure you get the whole word and not just the 
root.


Some sort of hashing algorithm would work also.  I think some M$ library 
has something, but dont quote me on it!




-----Original Message-----
From: Brandon Brownlee 
Sent: Tuesday, March 21, 2000 4:26 AM
To: How To
Subject: [proasp_howto] Case sensitivity when using Replace...


Hello all,

I am developing a quick little function to replace keywords in a glossary
with linked keywords... The definitions are coming out of a database. My
problem is, the Replace function is case sensitive, or so it seems. I have
tried using TextCompare instead of BinaryCompare, and it works, except 
when
the keywords have spaces in them, then it blows it up... (The Internet for
example...) Anyways, here is my existing code...

'=============================================================
'=============================================================
FUNCTION fncLinkMaker(Keyword, DefNum)
    Dim Def, EncKeyword

    SQL = "SELECT Definition"&DefNum&" FROM tblGlossary WHERE Keyword = 
'"&
Keyword &"'"
    Set rsLink = connObj.Execute(SQL)

    Def = rsLink("Definition"&DefNum)

    SQL = "SELECT Keyword FROM tblGlossary"
    Set rsKeyword = connObj.Execute(SQL)

    Do WHILE NOT rsKeyword.EOF
        EncKeyword = Server.URLEncode(rsKeyword("Keyword"))

        IF rsKeyword("Keyword") <> Keyword THEN
            Def = Replace(Def, rsKeyword("Keyword"), "<A
HREF='glossary.asp?Keyword="&EncKeyword&"'>"&rsKeyword("Keyword")&"</A>",
1, -1, 0)
        END IF

        rsKeyword.MoveNext
    Loop

    fncLinkMaker = Def
END FUNCTION
'=============================================================
'=============================================================

I could do it sloppily, by doing two Do Loops, one on a regular keyword 
and
another on LCase(Keyword), but this still wouldn't cover all of them. I
thought I'd see if anyone had a more graceful answer, and learn something
new. Thanks in advance!

Brandon


---
You are currently subscribed to proasp_howto. 

  Return to Index