Make your own free website on Tripod.com

InstantDB Project
About InstantDB
Project Mail Lists
Short History
Reporting Bugs
Screen Shots
3rd Party Examples
FAQs

Software
Downloads
Documentation
CVS Repositories
Roadmap
License

About Enhydra.org
Who We Are
News, Articles & Events
Getting Involved
Contact Us

Community
Demos
Contributions
Resources
Case Studies
On The Edge! -NEW-
Commercial Vendors


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: InstantDB: how to replace quotes with " ?


Thank you, Bill, for your code. That is what I need. I tried to use
StringBuffer myself, but I could not understand, what are those ints
replace(int1, int2 etc.)... javadoc is not self-explaining. Now I see, how
it should be used. Thank you very much for your help.

Philipp


----- Original Message -----
From: <wwg@tscnet.com>
To: <instantDB@enhydra.org>
Sent: Friday, October 20, 2000 3:35 AM
Subject: Re: InstantDB: how to replace quotes with &quot; ?


> Hi there -- this is more of a general Java question, but
> I'll try to help.  You need to employ the StringBuffer's
> replace, which will let you replace a substring with
> another.  String.replace only works on single chars.
> Here's the contents of a test app, test.java, that
> should help.  P.S. I don't guarantee that this is the
> most elegant way to do this ... and you could certainly
> make a generic replace method that would handle any
> substring substitution.  I'll leave that part for you
> ...   ;-)
>
> Good Luck!
> Bill Graham
>
> -------------------------------------
> import java.util.*;
>
> public class test
> {
>     public static void main(String[] args)
>     {
>         String str = "This is a \"String\" that I'm
> going to work on ...";
>         StringBuffer sb = new StringBuffer( str );
>
>         System.out.println("Original: " + str);
>
>         int pos;
>         while ( (pos = str.indexOf("\"")) > -1 )
>         {
>             sb.replace(pos, pos + 1, "&quot;");
>             str = sb.toString();
>         }
>         System.out.println("Double Quotes Fixed: " +
> str);
>
>         while ( (pos = str.indexOf("\'")) > -1 )
>         {
>             sb.replace(pos, pos + 1, "&#039;");
>             str = sb.toString();
>         }
>
>         System.out.println("Single Quotes Fixed: " +
> str);
>     }
> }
> ----------------------------------
>
> Quoting Philipp Chudinov <morpheus@basko.ru>:
>
> > Hi, all!
> >
> > I've made some kind of primitive "news management
> system" with
> > jsp&instantDB- just to make myself familiar with Java,
> JDBC and InstantDB.
> > One of the most stupid problem I've faced with is
> replacement of " with
> > &quot;. I need to convert " to &quot; because I need
> to show data in a
> > form - but if there is a " symbol, the form in html
> does not render
> > properly
> > (<input type="blah" value="hereis some value and if
> here is also
> > some"quotes" this form is not a "valid html
> document"">) - also, how is it
> > possible to convert ' to smth alse? InstantDB
> understands \' fine, but,
> > imagine, you should put escape symbol every time you
> need to edit a
> > story...
> >
> > When I try to use .replace() method of
> java.lang.String, I get an error (I
> > am new to java and I can not understand why it
> produces an error... In
> > vbscript (asp) it is a very simple function
> replce(inputstr, what to
> > replce,
> > what replace with)...)
> >
> > Maybe, someone can explain me, how things like this
> gets processed usually?
> >
> > P.S. sorry for my poor english.
> >
> >
> --------------------------------------------------------------------------
---
> > To unsubscribe from this mailing list, send email to
> majordomo@enhydra.org
> > with the text "unsubscribe instantdb" in the body of
> the email.
> > If you have other questions regarding this mailing
> list, send email to
> > the list admin at owner-instantdb@enhydra.org.
> >
>
>
> =========================================
> This mail sent through Sinclair's WebMail
>       http://mail.sinclair.net
>
> --------------------------------------------------------------------------
---
> To unsubscribe from this mailing list, send email to majordomo@enhydra.org
> with the text "unsubscribe instantdb" in the body of the email.
> If you have other questions regarding this mailing list, send email to
> the list admin at owner-instantdb@enhydra.org.

-----------------------------------------------------------------------------
To unsubscribe from this mailing list, send email to majordomo@enhydra.org
with the text "unsubscribe instantdb" in the body of the email.
If you have other questions regarding this mailing list, send email to
the list admin at owner-instantdb@enhydra.org.