Simple string modification

I am completely new to JSP and I have a string which contains spaces but I need to replace all of the spaces with underscores (_)? Any help anyone can give me would be much appreciated!

I think you are new to JAVA too..
ok fine
use this method
String replace(char oldChar, char newChar)
Example
String sSpace = "A ";
sSpace = sSpace.replace(' ','_');

Similar Messages

  • Simple String Compression Functions

    Hi all !
    I need two simple String compression functions, like
    String compress(String what)
    and
    String decompress(String what)
    myString.equals(decompress(compress(myString)))
    should result in true.
    Primarily I want to encode some plain text Strings so they are not too easy to read, and compression would be a nice feature here.
    I already tried the util.zip package, but that one seems to need streams, I simply need Strings.
    Any ideas ??
    thx
    Skippy

    It does not do any compression, in fact it does
    expansion to better encrypt the string (about 50%).How does that work? You want encryption to
    decrease entropy.Why in the world do you say that, pjt33? What a very odd statement indeed. I sure hope you don't work in security, or I do hope you work in security if I'm a bad guy, or a competitor.
    Let's say you had a 6-character string you wanted to encrypt.
    Well, if you didn't increase the entropy, any 6-character plaintext string would have a 6-character encoded equivalent. And if you decreased entropy (e.g. coding the most commonly used words to shorter strings,) it gets even easier to decrypt.
    Presumably there would be no hash collisions, after all, you want this to be reversible.
    Hash collisions decrease entropy too, and, by doing so, make it easier to find a plaintext string that happens to hash to a certain value. This is a Bad Thing.
    Now, to decode this, the Bad Guy only has to consider the set of 6-character strings and their hash values. You could even precalculate all of the common dictionary words, and everything with common letters and punctuation, making decryption virtually instantaneous. Especially if you had decreased the entropy in the signal, making fewer things I had to try.
    But somebody who increased the entropy of their signal by adding random bits and increasing the encrypted size of the message to, say, 64 characters, would make it a lot harder to decrypt.
    The ideal encryption system is pure noise; pure randomized entropy. An indecipherable wall of 0 and 1 seemingly generated at random. Statistical methods can't be used against it; nothing can be deciphered from it; it's as decipherable and meaningless as radio hiss. Now that's encryption!

  • Write a simple string to a file.

    I have a string that is formatted with new lines that I want to write to a file as is. I have not been able to create a File Partner Link that can successfully write the content.
    The opaque approach creates an empty file.
    I have tried defining a new schema as a string, a delimited and a fixed length and the closest I have come is getting the last line written with fixed length.
    This is the input schema. I want to write the file element. The complex_child element contains values I would use to build the file name.
    <xs:complexType name="complex_parent_type">
    <xs:sequence>
    <xs:element name="complex_child" type="ns1:complex_child_type"/>
    <xs:element name="file" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>
    Anybody have any success? I would think this should be a simple process. We would prefer not to use embedded Java.
    Thanks,
    Wes.

    Hi Wes,
    You could try using this schema:
    <?xml version="1.0" ?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
    targetNamespace="..."
    xmlns:tns="..."
    elementFormDefault="qualified" attributeFormDefault="unqualified"
    nxsd:encoding="US-ASCII" nxsd:stream="chars"
    nxsd:version="NXSD" >
    <xsd:element name="file" type="xsd:string" nxsd:style="terminated"
                                  nxsd:terminatedBy="${eof}">
    </xsd:element>
    </xsd:schema>
    You could copy over the contents of the string that you want to write out into the element above and then use the "invoke" on a file adapter PL to write it out.
    Regards,
    Narayanan

  • Simple string / bytes problem

    Hi
    I'm basically trying to simulate DES in java from scratch (so no use of existing API's or anything). I've got a basic idea of how DES works (use of a feistel cipher).
    So to start off I'm trying to get the bytes of a string with this simple program:
    public class Test {
         public static void main(String[] args) {     
              String testString = "hello";
              System.out.println(testString.getBytes());
    }The output consists of some characters (namely numbers, letters and 1 special character).
    But when I change the variable testString to some other String, complie and run I still get the same output even though the String is different. Also why are there 9 characters for a String thats only 5 characters long?
    Thanks

    When you use System.out.println( something ) it uses to the toString() method of the object referenced by 'something'. When the something is an array such as an array of bytes the toString() methed returns a pseudo reference to the array which in no way reflects the content of the array.
    If you just want to see the content of the array then use Arrays.toString(something) to generate a String representation of the content of the array.
    Also, the use of String.getBytes() will convert the String to bytes using your default character encoding. This is rarely what you want since the result may depend on which platform you are working on. In my view, the safest and best approach is to explicitly define the encoding and since it will encode ALL characters one can throw at it I always use utf-8. So, to convert a String to bytes I would usebyte[] bytesOfString = "your string".getBytes("utf-8");and to convert them back to a String I would useString yourString = new String(bytesOfString,"utf-8");One final point, do not assume that an apparently random array of bytes such as one gets from DES encryption can be converted to a String using the above. In general it can't because not all bytes and byte sequences are valid for a particular character encoding. If you absolutely have to have a String representation then you should encode (not encrypt) the bytes using something like Base64 or Hex encoding.
    Edited by: sabre150 on Jan 27, 2008 3:04 PM

  • String modification

    Hi,
    I got one situation when working with java.lang.String. I would like to explain with one simple example so that I can be clear.
    originalString = "HANDICRAFTS (MADE OF BRASS, COPPER, IRON, WOOD, BAMBOO, WICKER, PAPER, PAPER MACHE, LEATHER, )".
    I would like to replace the set of characters "ER" with "RE" whereever it occurs. so the o/p string like
    " HANDICRAFTS (MADE OF BRASS, COPP"-->RE<--", IRON, WOOD, BAMBOO, WICK"-->RE<--", PAP"-->RE<--", PAP"-->RE<--" MACHE, LEATH"-->RE<--",)".
    like this.
    Note:- There is a function called java.lang.String.replaceAll(String str1,String str2) in jdk1.4. But I need to work on jdk1.3 where this method is not supported.So I request you all to help with the sample code of that logic.
    Thank you.

    http://onesearch.sun.com/search/developers/index.jsp?qt=1.3+replaceall&col=devforums

  • Havin probs drawing a simple string

    hi 2 all
    i've got this simple applet,but it doesn't really what i want!i only see a gry rect!but he has to draw a string!
    import java.applet.*;
    import java.net.*;
    import java.io.*;
    import java.awt.*;
    public class CCounter1 extends Applet {
    Font anzeiger;
    public void init() {
    anzeiger=new Font("Arial",Font.BOLD,16);
    public String readFile(String f) {
    try {
    String zahl1="";
    String aLine = "";
    URL source = new URL(getCodeBase(), f);
    BufferedReader br =new BufferedReader(new InputStreamReader(source.openStream()));
    while(null != (aLine = br.readLine()))
    zahl1.concat(zahl1);
    br.close();
    return aLine;
    catch(Exception e) {
    e.printStackTrace();
    return null;
    public void paint(Graphics g){
    setBackground(Color.gray);
    g.setColor(Color.white);
    setFont(anzeiger);
    g.fillRect(100,100,100,100);
    g.drawString(readFile("besucher.hansi"),10,20);
    g.drawString("Hallo",200,200);

    You set the color to white... fill the area and then paint a string (with the same white color)
    first... set a color... fill it... then set another color... draw your string... done
    Grtz David

  • Simple String Encryption

    HI,
    I have been serching around on here for encyption methods but there seems to be soo many i not sure which ones would be good for me.
    All i want to do is encypt and decrypt a String record. The encryption doesnt have to be particulary safe but must work for all possible charaters. Basically i am saving records to a text file and i dont want someone to be able to open the text file and read the contents.
    I would like to make it as simple as possible so i can just use it like:
    String record = "This is the record";
    // Encrypted Record
    String encRecord = Encryption.encrypt(record);
    // Decripted Record
    String decRecord = Encryption.decrypt(record);Can anyone stear me in the right direction or give me some sample code i can study.
    Thank you in advance
    ed

    Here is simple encryption routine that I just wrote that I bet would keep someone
    stumped for a while.
    * This is a simple encryption class that uses simple character substitution.
    * To keep the pattern from being obvious the shift factor is a function of the current character's
    * position in the source string. This makes sure that all letters aren't encrypted to the same value.
    * Usage: To encrypt a string just pass it to the encrypt method.
    *         String encryptedString = Encryptor.encrypt("Some string.");
    *        To decrypt a string just pass the encrypted string to the decrypt method.
    *         String decryptedString = Encryptor.decrypt(encryptedString);
    class Encryptor
      static final byte [] shiftFactor = {2,5,7,9,13,17,19};
      static final int modulo = shiftFactor.length;
      static public String encrypt(String s)
         char [] ba = s.toCharArray();
         for (int i = 0; i < ba.length; i++)
              ba[i] += shiftFactor[i%modulo];
        return new String(ba);
      static public String decrypt(String s)
         char [] ba = s.toCharArray();
         for (int i = 0; i < ba.length; i++)
              ba[i] -= shiftFactor[i%modulo];
         return new String(ba);
      public static void main(String [] args)
         String [] test = {"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz,./<>?;':\"[]{}-=_+!@#$%^&*()`~",
                           "Now is the time for all good men \n to come to the aid of their country."};
        for (int i = 0; i < test.length; i++)
              System.out.println(test);
              String encrypted = Encryptor.encrypt(test[i]);
              System.out.println(encrypted);
              System.out.println(Encryptor.decrypt(encrypted) + "\n");

  • DB Adapter 902 binding exception while passing parameters for simple string

    Hi,
    I have an PlSQL API with two input paramters of string type... But this is only started after XML validation TRUE on the BPM server.
    The error is
    <bindingFault xmlns="http://schemas.oracle.com/bpel/extension"><part name="code"><code>902</code>
    </part><part name="detail"><detail>
    Internal Exception: java.sql.SQLException: ORA-00902: invalid datatype
    Error Code: 902</detail>
    </part><part name="summary"><summary>file:/oracle/product/10.1.3/soa/bpel/domains/Website/tmp/.bpel_BPELProcess1_1.0_c64929dfd2dacf95db3c9da081c1797d.tmp/callingAPI.wsdl [ callingAPI_ptt::callingAPI(InputParameters,OutputParameters) ] - WSIF JCA Execute of operation 'callingAPI' failed due to: Error while trying to prepare and execute an API.
    An error occurred while preparing and executing the XXRBA.XXRBA_WEB_ADAPTER.FETCH_CUSTOMERS API. Cause: java.sql.SQLException: ORA-00902: invalid datatype
    [Caused by: ORA-00902: invalid datatype
    ; nested exception is:
         ORABPEL-11811
    Error while trying to prepare and execute an API.
    An error occurred while preparing and executing the XXRBA.XXRBA_WEB_ADAPTER.FETCH_CUSTOMERS API. Cause: java.sql.SQLException: ORA-00902: invalid datatype
    [Caused by: ORA-00902: invalid datatype
    Check to ensure that the API is defined in the database and that the parameters match the signature of the API. Contact oracle support if error is not fixable.
    </summary>
    </part></bindingFault>
    The input XSD parameters in BPEL input
    <element name="input" type="string"/>
    The input XSD parameters in ADAPTER
    <element name="P_WEB_ACCOUNT" type="string" db:index="1" db:type="VARCHAR2" minOccurs="0" nillable="true"/>
    <element name="P_SOLICITED_ONLY" type="string" db:index="2" db:type="VARCHAR2" minOccurs="0" nillable="true"/>
    The assignment I am doing in the .bple file is
    <assign name="Assign_1">
    <copy>
    <from expression="bpws:getVariableData('inputVariable','payload','/client:BPELProcess1ProcessRequest/client:input')"/>
    <to variable="Invoke_1_callingAPI_InputVariable" part="InputParameters"
    query="/ns2:InputParameters/ns2:P_WEB_ACCOUNT"/>
    </copy>
    <copy>
    <from expression="string('o')"/>
    <to variable="Invoke_1_callingAPI_InputVariable" part="InputParameters"
    query="/ns2:InputParameters/ns2:P_SOLICITED_ONLY"/>
    </copy>
    </assign>
    --Khaleel                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    You have an attribute type in an object service that is supposed to be numeric, but when reading form the database it seems that is retrieving a non-numeric content...
    Cheers,
    Vlad

  • UTF-8 working in JSP not in JavaBean (when assigned to a simple String)

    I am struggling with for last few hours. All I am doing is
    public class Text extends Object implements Serializable {
    public static Hashtable ht = new Hashtable();
    public static void initL10N(){
    public static String xyz = "&#2310;&#2346;&#2325;&#2375;";
    ht.put("hindi",xyz);
    in a JavaBean and trying to access the string in a Jsp Out.jsp as <%=Text.ht.get("hindi")%> I am getting Junk characters.
    But to my surprise: If I do that in a jsp: as (since I declared the ht as public static it's accessable to the new JSP called L10NInit.jsp
    <%
    Text.ht.put("hindi2","&#2310;&#2346;&#2325;&#2375;")l
    %>
    and execute the Out.jsp and then execute my orginal jsp to get the string as <%=Text.ht.get("hindi2")%> it displays beautifully.
    I tried every thing else before turning to this forum. Please help.
    Environment: NetBeans5.5

    In the JSP also I am assigining straignt hindi chars (some how forum displayed entities) as &#2357;&#2376;&#2358;&#2381;&#2357;&#2367;&#2325;

  • Method to Format a string column containing HTML tags as simple string.

    Hello,
    I am working with formating a string column which holds Html tags.
    I want to remove these tags from the actual data which has to be shown on the BI Publisher report.
    Can you suggest how can we format this in the DataSet designer of BI publisher so that my data is recognised on the Layout designer.
    I have been trying to create an expression using the "Add Element by Expression" option to format this html tag data as normal string without the tags.
    Can you suggest if this is the correct method to do this.
    I found this below code being used in an existing DateSet but i am not able to recreate a similar formating on this kind of data column.
    <![CDATA' || '['|| TO_CLOB(SUCCESS_CRITERIA) || ']' || ']>
    Kindly suggest if you have any idea on the above mentioned issue.
    Thanks,
    Shweta

    And read this:
    Navigate yourself around pitfalls related to the Runtime.exec() method
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Simple string optimization question

    ABAPpers,
    Here is the problem description:
    In a SELECT query loop, I need to build a string by concatenating all the column values for the current row. Each column is represented as a length-value pair. For example, let's say the current values are:
    Column1 (type string)  : 'abc          '
    Column2 (type integer) : 7792
    Column3 (type string)  : 'def                    '
    The resulting string must be of the form:
    0003abc000477920003def...
    The length is always represented by a four character value, followed by the actual value.
    Note that the input columns may be of mixed types - numeric, string, date-time, etc.
    Given that data is of mixed type and that the length of each string-type value is not known in advance, can someone suggest a good algorithm to build such a result? Or, is there any built-in function that already does something similar?
    Thank you in advance for your help.
    Pradeep

    Hi,
    At the bottom of this message, I have posted a program that I currently wrote. Essentially, as I know the size of each "string" type column, I use a specific function to built the string. For any non-string type column, I assume that the length can never exceed 25 characters. As I fill 255 characters in the output buffer, I have to write the output buffer to screen.
    The reason I have so many functions for each string type is that I wanted to optimize concatenate operation. Had I used just one function with the large buffer, then "concatenate" statement takes additional time to fill the remaining part of the buffer with spaces.
    As my experience in ABAP programming is limited to just a couple of days, I'd appreciate it if someone can suggest me a better way to deal with my problem.
    Thank you in advanced for all your help. Sorry about posting such a large piece of code. I just wanted to show you the complexity that I have created for myself :-(.
    Pradeep
    REPORT ZMYREPORTTEST no standard page heading line-size 255.
    TABLES: GLPCA.
    data: GLPCAGL_SIRID like GLPCA-GL_SIRID.
    data: GLPCARLDNR like GLPCA-RLDNR.
    data: GLPCARRCTY like GLPCA-RRCTY.
    data: GLPCARVERS like GLPCA-RVERS.
    data: GLPCARYEAR like GLPCA-RYEAR.
    data: GLPCAPOPER like GLPCA-POPER.
    data: GLPCARBUKRS like GLPCA-RBUKRS.
    data: GLPCARPRCTR like GLPCA-RPRCTR.
    data: GLPCAKOKRS like GLPCA-KOKRS.
    data: GLPCARACCT like GLPCA-RACCT.
    data: GLPCAKSL like GLPCA-KSL.
    data: GLPCACPUDT like GLPCA-CPUDT.
    data: GLPCACPUTM like GLPCA-CPUTM.
    data: GLPCAUSNAM like GLPCA-USNAM.
    data: GLPCABUDAT like GLPCA-BUDAT.
    data: GLPCAREFDOCNR like GLPCA-REFDOCNR.
    data: GLPCAAWORG like GLPCA-AWORG.
    data: GLPCAKOSTL like GLPCA-KOSTL.
    data: GLPCAMATNR like GLPCA-MATNR.
    data: GLPCALIFNR like GLPCA-LIFNR.
    data: GLPCASGTXT like GLPCA-SGTXT.
    data: GLPCAAUFNR like GLPCA-AUFNR.
    data: data(255).
    data: currentPos type i.
    data: lineLen type i value 255.
    data len(4).
    data startIndex type i.
    data charsToBeWritten type i.
    data remainingRow type i.
    SELECT GL_SIRID
    RLDNR
    RRCTY
    RVERS
    RYEAR
    POPER
    RBUKRS
    RPRCTR
    KOKRS
    RACCT
    KSL
    CPUDT
    CPUTM
    USNAM
    BUDAT
    REFDOCNR
    AWORG
    KOSTL
    MATNR
    LIFNR
    SGTXT
    AUFNR into (GLPCAGL_SIRID,
    GLPCARLDNR,
    GLPCARRCTY,
    GLPCARVERS,
    GLPCARYEAR,
    GLPCAPOPER,
    GLPCARBUKRS,
    GLPCARPRCTR,
    GLPCAKOKRS,
    GLPCARACCT,
    GLPCAKSL,
    GLPCACPUDT,
    GLPCACPUTM,
    GLPCAUSNAM,
    GLPCABUDAT,
    GLPCAREFDOCNR,
    GLPCAAWORG,
    GLPCAKOSTL,
    GLPCAMATNR,
    GLPCALIFNR,
    GLPCASGTXT,
    GLPCAAUFNR) FROM GLPCA
    perform BuildFullColumnString18 using GLPCAGL_SIRID.
    perform BuildFullColumnString2 using GLPCARLDNR.
    perform BuildFullColumnString1 using GLPCARRCTY.
    perform BuildFullColumnString3 using GLPCARVERS.
    perform BuildFullColumnString4 using GLPCARYEAR.
    perform BuildFullColumnString3 using GLPCAPOPER.
    perform BuildFullColumnString4 using GLPCARBUKRS.
    perform BuildFullColumnString10 using GLPCARPRCTR.
    perform BuildFullColumnString4 using GLPCAKOKRS.
    perform BuildFullColumnString10 using GLPCARACCT.
    perform BuildFullColumnNonString using GLPCAKSL.
    perform BuildFullColumnNonString using GLPCACPUDT.
    perform BuildFullColumnNonString using GLPCACPUTM.
    perform BuildFullColumnString12 using GLPCAUSNAM.
    perform BuildFullColumnNonString using GLPCABUDAT.
    perform BuildFullColumnString10 using GLPCAREFDOCNR.
    perform BuildFullColumnString10 using GLPCAAWORG.
    perform BuildFullColumnString10 using GLPCAKOSTL.
    perform BuildFullColumnString18 using GLPCAMATNR.
    perform BuildFullColumnString10 using GLPCALIFNR.
    perform BuildFullColumnString50 using GLPCASGTXT.
    perform BuildFullColumnString12 using GLPCAAUFNR.
    ENDSELECT.
    if currentPos > 0.
      move '' to datacurrentPos.
      write: / data.
    else.
      write: / '+'.
    endif.
    data fullColumn25(29).
    data fullColumn1(5).
    Form BuildFullColumnString1 using value(currentCol). 
      len = STRLEN( currentCol ).
      concatenate len currentCol into fullColumn1.
      data startIndex type i.
      data charsToBeWritten type i.
      charsToBeWritten = STRLEN( fullColumn1 ).
      data remainingRow type i.
      do.
        remainingRow = lineLen - currentPos.
        if remainingRow > charsToBeWritten.
          move fullColumn1+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          currentPos = currentPos + charsToBeWritten.
          exit.
        endif.
        if remainingRow EQ charsToBeWritten.
          move fullColumn1+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          write: / data.
          currentPos = 0.
          exit.
        endif.
        move fullColumn1+startIndex(remainingRow) to
            data+currentPos(remainingRow).
        write: / data.
        startIndex = startIndex + remainingRow.
        charsToBeWritten = charsToBeWritten - remainingRow.
        currentPos = 0.
      enddo.
    EndForm.
    data fullColumn2(6).
    Form BuildFullColumnString2 using value(currentCol). 
      len = STRLEN( currentCol ).
      concatenate len currentCol into fullColumn2.
      data startIndex type i.
      data charsToBeWritten type i.
      charsToBeWritten = STRLEN( fullColumn2 ).
      data remainingRow type i.
      do.
        remainingRow = lineLen - currentPos.
        if remainingRow > charsToBeWritten.
          move fullColumn2+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          currentPos = currentPos + charsToBeWritten.
          exit.
        endif.
        if remainingRow EQ charsToBeWritten.
          move fullColumn2+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          write: / data.
          currentPos = 0.
          exit.
        endif.
        move fullColumn2+startIndex(remainingRow) to
            data+currentPos(remainingRow).
        write: / data.
        startIndex = startIndex + remainingRow.
        charsToBeWritten = charsToBeWritten - remainingRow.
        currentPos = 0.
      enddo.
    EndForm.
    data fullColumn3(7).
    Form BuildFullColumnString3 using value(currentCol). 
    EndForm.
    data fullColumn4(8).
    Form BuildFullColumnString4 using value(currentCol). 
    EndForm.
    data fullColumn50(54).
    Form BuildFullColumnString50 using value(currentCol). 
    EndForm.
    Form BuildFullColumnNonString using value(currentCol). 
      move currentCol to fullColumn25.
      condense fullColumn25.     
      len = STRLEN( fullColumn25 ).
      concatenate len fullColumn25 into fullColumn25.
      data startIndex type i.
      data charsToBeWritten type i.
      charsToBeWritten = STRLEN( fullColumn25 ).
      data remainingRow type i.
      do.
        remainingRow = lineLen - currentPos.
        if remainingRow > charsToBeWritten.
          move fullColumn25+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          currentPos = currentPos + charsToBeWritten.
          exit.
        endif.
        if remainingRow EQ charsToBeWritten.
          move fullColumn25+startIndex(charsToBeWritten) to
            data+currentPos(charsToBeWritten).
          write: / data.
          currentPos = 0.
          exit.
        endif.
        move fullColumn25+startIndex(remainingRow) to
            data+currentPos(remainingRow).
        write: / data.
        startIndex = startIndex + remainingRow.
        charsToBeWritten = charsToBeWritten - remainingRow.
        currentPos = 0.
      enddo.
    EndForm.

  • Query  String Modification

              Any ideas on how to modify the query string on the fly.
              Thanx,
              Tajdar
              

              Any ideas on how to modify the query string on the fly.
              Thanx,
              Tajdar
              

  • Very simple Strings Question

    Hi All:
    I am stuck with a small situation, I would appreciate if someone can help me with that. I have 2 strings:
    String 1 - "abc"
    String 2 - "I want to check if abc is in the middle"
    How can I check if the string 1 "abc" is in the middle of the string 2. I mean the String 2 does not start with "abc" and it does not end with "abc", I want to check if it is somewhere between the string.
    Thanks,
    Kunal

    int i = s2.indexOf(s1);
    if((i > 0) && ((i + s1.length()) < s2.length())) {
       // somewhere in the middle
    } else if(i == 0) {
       // start
    } else if((i + s1.length()) == s2.length()) {
       // end
    } else if(i == -1) {
       // nowhere
    }

  • Simple String replacement problem

    I want to replace every string of the type:
    "^\\d+,[^,]+,,[^,]*,[^,]*$"
    to:
    "^\\d+,[^,]+,1,[^,]*,[^,]*$"
    So that "1234,something,,something,something" becomes "1234,something,1,something,something"
    What's the best way to do this?

    What are your EXACT requirements?
    Do you want to replace all ,, with ,1, ?
    Only a ,, that comes after number,something?
    Right now, it looks like replaceFirst(",,", ",1,") will work. I doubt that's what you want, but there are probably a whole bunch of different regexes that could turn that input into that output.

  • Simple string question

    I want to compare two strings, suppose that:
    first string = "-Hello"
    second string = " -Hello"
    I want that both return same result.
    A lot of thanks!

    i would filter out all whitespaces first and the use the string.compare() function.
    write a open methode that allows you to filer out any char in any string and returns the filtered string. you can do so by building a while (indexOf(char)) loop and cutting out the unwanted chars with the subString() command.

Maybe you are looking for

  • How to import/export in Pl/SQL ?

    Hello I want to write a procedure in PL/SQL which will be copying one user's schema to another. I have Oracle 9i on Windows 2000. My first idea was to use IMP EXP commands, but i need to execute this commands from PL/SQL procedure. How can I do this,

  • I'm in deep trouble and tears with 10.6.5, Pse help

    Have a big job to finish on my iMac, my primary machine. Was running just fine on 10.6.4 but installed 10.6.5 downloaded off the normal software update, so I can update my iPad when OS4.2 comes out. The installation appeared to go fine. Machine resta

  • How to set up autofil in mail

    Lost everything......now autofil only gives my name.  I use this a lot & would like to get it correct again

  • HT5137 what does the circle with a lock in it mean?

    What does the circle with a lock in it mean? And how do I make it go away?

  • Repairing permissions on a new MAC PRO .... why are they NOT repairing?

    Hi. Thanks for reading this. I just got a MAC PRO running OS 10.5.7 Processor is a 2 x 2.93 GHz Quad Core Intel Xeon Four 1 TB internal hard drives 6 GB RAM I am up to date on everything. (Just ran software update this morning before typing this) I K