Substring Location in String

I am having a problem using substring to select/filter.  The substring selection is not holding to the specified locations in the string.  Instead, it finds any matching text in the entire string.
For reference, my web site intent is,
1. A single XML master data base contains all photographs for display.  My XML data set does not have quotes.
2. Spry tabbed panels are used to select galleries (Spry regions) (e.g. roses, Big Sur Coast, etc) from the master data base.  There are a dozen galleries.
3. Thumbnails of a gallery are displayed in the content panel.
4. Selecting a thumbnail displays a large view of the selected photo in a separate div (Spry detail region).
The galleries are filtered using spry:test, with the "subject" variable compared against a specified value (i.e. rose, Monterey, Salinas, etc.).
The "2010 Photographs" gallery is determined by the year of the photo.  In the "name" variable, the first 6 digits are the date (month, day, year).  I've set up the spry:test with substring as follows,
spry:test="'substring({name},5,2)'.search ('10 ') != -1;"
This is to obtain the 5th and 6th locations of "name" variable and compare it with the "10 ".
A sample of the "photo" node follows,
<photo>
<name>032010 Lover's Pt, Pacific Grove 02a web.jpg</name>
<width>599</width>
<height>400</height>
<thumbname>032010 Lover's Pt, Pacific Grove 02a thumbnail.jpg.</thumbname>
<thumbwidth>150</thumbwidth>
<thumbheight>100</thumbheight>
<subject>night</subject>
<description>West side of Lover's Point, Pacific Grove, Ca.; the surf was unusually calm.  The glow reflecting on the clouds and the bay is from the town of Santa Cruz.</description>
</photo>
<photo>
<name>090609 Pelican over Pacific Grove 02a 8x10 web.jpg</name>
<width>500</width>
<height>400</height>
<thumbname>090609 Pelican over Pacific Grove 02a 8x10 thumbnail.jpg</thumbname>
<thumbwidth>125</thumbwidth>
<thumbheight>100</thumbheight>
<subject>animal</subject>
<description>Pelican caught in flight; using a flash, this photograph was taken at dusk; Pacific Grove, Ca.</description>
</photo>
Both of these nodes would be selected with the "10 " criteria.  However the second one is not from the year 2010.
The full source code is shown below.
My search of these forums and the Internet have indicated that this should work.  Please explain what I am missing or doing incorrectly in the code.
I thank you.
Scott
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>EnvisionMoore</title>
<style type="text/css">
<!--
body {
background-color: #FFF;
text-align: center;
margin: 0px;
padding: 0px;
#wrapper {
width: 98%;
margin-top: 10px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
border: 0px dashed #F0F;
position: absolute;
left: 1px;
top: 1px;
height: 825px;
background-color: #FFE4CA;
#leftColumn {
float: left;
height: 700px;
width: 400px;
position: relative;
left: 0px;
top: 0px;
#header {
height: 125px;
font-size: 24px;
font-style: italic;
vertical-align: bottom;
padding: 0px;
text-align: center;
float: right;
width: 50%;
border: 0px solid #F00;
position: relative;
top: 0px;
right: 0px;
#selectedPhoto {
height: 600px;
font-size: 24px;
font-style: italic;
vertical-align: middle;
padding: 0px;
text-align: center;
margin-top: 135px;
width: 650px;
border: 0px solid #0F0;
position: absolute;
right: -1px;
bottom: 1px;
-->
</style>
<script src="SpryAssets/xpath.js" type="text/javascript"></script>
<script src="SpryAssets/SpryData.js" type="text/javascript"></script>
<script type="text/javascript">
<!--
var name;
var width;
var height;
var thumbname;
var thumbwidth;
var thumbheight;
var subject;
var description;
var thumbnail;
var dsphoto;
var dsdata;
//-->
</script>
<script type="text/javascript">
var dsdata = new Spry.Data.XMLDataSet("EM_photo.xml", "/gallery");
var dsphoto = new Spry.Data.XMLDataSet("EM_photo.xml", "gallery/photos/photo");
</script>
<script type="text/javascript">
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
</script>
<script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
<link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
  <div id="leftColumn">
    <div id="TabbedPanels1" class="TabbedPanels">
      <ul class="TabbedPanelsTabGroup">
        <li class="TabbedPanelsTab" tabindex="0">Welcome</li>
        <li class="TabbedPanelsTab" tabindex="0">Mechanical Engineering</li>
        <li class="TabbedPanelsTab" tabindex="0">Photography</li>
      </ul>
      <div class="TabbedPanelsContentGroup">
        <div class="TabbedPanelsContent">
          <h1><br />
  <br />
  <br />
  <br />Welcome!
  <br />
          </h1>
        </div>
        <div class="TabbedPanelsContent">Mechanical Engineering - Content 2</div>
        <div class="TabbedPanelsContent"> <!-- Photography - Content 3 -->
          <div id="TabbedPanels2" class="TabbedPanels">
            <ul class="TabbedPanelsTabGroup">
              <li class="TabbedPanelsTab" tabindex="0">2010 Photographs</li>
              <li class="TabbedPanelsTab" tabindex="0">Roses</li>
              <li class="TabbedPanelsTab" tabindex="0">Calla Lilies</li>
              <li class="TabbedPanelsTab" tabindex="0">Other Blossoms and Leaves</li>
              <li class="TabbedPanelsTab" tabindex="0">Pacific Grove Beach</li>
              <li class="TabbedPanelsTab" tabindex="0">Monterey Harbor and Beach</li>
              <li class="TabbedPanelsTab" tabindex="0">Big Sur Coast</li>
              <li class="TabbedPanelsTab" tabindex="0">Salinas Valley</li>
              <li class="TabbedPanelsTab" tabindex="0">Animals</li>
              <li class="TabbedPanelsTab" tabindex="0">Night</li>
              <li class="TabbedPanelsTab" tabindex="0">Church</li>
              <li class="TabbedPanelsTab" tabindex="0">Other</li>
            </ul>
            <div class="TabbedPanelsContentGroup-2">
              <div class="TabbedPanelsContent-2">
                <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = {thumbwidth}px height = {thumbheight}px spry:repeat="dsphoto" spry:test="'substring({name},5,2)'.search ('10 ') != -1;" ; onclick="dsphoto.setCurrentRow('{ds_RowID}');" /></div>
              </div>
              <div class="TabbedPanelsContent-2">
                <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = {thumbwidth}px height = {thumbheight}px spry:repeat = "dsphoto" spry:test="'{subject}'.search (/rose/) !=-1;" onclick="dsphoto.setCurrentRow('{ds_RowID}');" /></div>
              </div>
              <div class="TabbedPanelsContent-2">
                <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = {thumbwidth}px height = {thumbheight}px spry:repeat="dsphoto" spry:test="'{subject}'.search (/callalily/) !=-1;" onclick="dsphoto.setCurrentRow('{ds_RowID}');" /></div>
              </div>
              <div class="TabbedPanelsContent-2">
                <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = "{thumbwidth}px" height = "{thumbheight}px" onclick="dsphoto.setCurrentRow('{ds_RowID}');" spry:repeat="dsphoto" spry:test="'{subject}'.search (/blossom/) !=-1;" /></div>
              </div>
              <div class="TabbedPanelsContent-2">
                <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = "{thumbwidth}px" height = "{thumbheight}px" onclick="dsphoto.setCurrentRow('{ds_RowID}');" spry:repeat = "dsphoto" spry:test="'{subject}'.search (/^p/) !=-1;" /></div>
              </div>
              <div class="TabbedPanelsContent-2">
                <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = {thumbwidth}px height = {thumbheight}px spry:repeat="dsphoto" spry:test="'{subject}'.search (/Monterey/) !=-1;" onclick="dsphoto.setCurrentRow('{ds_RowID}');" /></div>
              </div>
              <div class="TabbedPanelsContent-2">
                <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = {thumbwidth}px height = {thumbheight}px spry:repeat="dsphoto" spry:test="'{subject}'.search (/bigsurcoast/) !=-1;" onclick="dsphoto.setCurrentRow('{ds_RowID}');" /></div>
              </div>
              <div class="TabbedPanelsContent-2">
                <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = {thumbwidth}px height = {thumbheight}px spry:repeat="dsphoto" spry:test="'{subject}'.search (/Salinas/) !=-1;" onclick="dsphoto.setCurrentRow('{ds_RowID}');" /></div>
              </div>
              <div class="TabbedPanelsContent-2">
                <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = {thumbwidth}px height = {thumbheight}px spry:repeat="dsphoto" spry:test="'{subject}'.search (/animal/) !=-1;" onclick="dsphoto.setCurrentRow('{ds_RowID}');" /></div>
              </div>
              <div class="TabbedPanelsContent-2">
                <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = {thumbwidth}px height = {thumbheight}px spry:repeat="dsphoto" spry:test="'{subject}'.search (/night/) !=-1;" onclick="dsphoto.setCurrentRow('{ds_RowID}');" /></div>
              </div>
              <div class="TabbedPanelsContent-2">
                <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = {thumbwidth}px height = {thumbheight}px spry:repeat="dsphoto" spry:test="'{subject}'.search (/church/) !=-1;" onclick="dsphoto.setCurrentRow('{ds_RowID}');" /></div>
              </div>
              <div class="TabbedPanelsContent-2">
                <div spry:region="dsphoto dsdata"> <img src="{dsdata::thumbnail/@base}{thumbname}" width = {thumbwidth}px height = {thumbheight}px spry:repeat="dsphoto" spry:test="'{subject}'.search (/other/) !=-1;" onclick="dsphoto.setCurrentRow('{ds_RowID}');" /></div>
              </div>
            </div>
          </div>
        </div>
        <!-- End "Photography Content 3" Tabbed Panels Content. -->
      </div>
    </div>
  </div><!-- End div "leftColumn" -->
  <div id="header">
    <p>Envision Moore</p>
    <p>      Mechanical Engineering and Photography</p>
    <p>      Scott W. Moore</p>
  </div><!-- End div "header". -->
  <div id="selectedPhoto">
  <div id="Selection" spry:detailregion = "dsphoto dsdata"  >
<!-- Selected photographs are 400px tall. -->
<img src="Photo-Email/{name}" width = {width}px height = {height}px align="center" />
  <br />
Description<br /><br />
<p> {dsphoto::email/base}{description} </p>
</div>
</div> <!-- End div "selectedPhoto". -->
</div> <!-- End div "wrapper" -->
<script type="text/javascript">
<!--
var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1");
var TabbedPanels2 = new Spry.Widget.TabbedPanels("TabbedPanels2");
//-->
</script>
</body>
</html>

Moore6931 wrote:
Ben
I thank you but the change of the starting location did not correct the problem.  I copied your script and pasted it into the source code but the results were the same set of thumbnails; several of the thumbnails are prior to (20)10.
In considering the results, I decided to try,
spry:test="'{name}'.search  ('10 ') != -1;"
This filter gave the same result as,
spry:test="'substring({name},4,2)'.search  ('10 ') != -1;"
I found out that the "4,2" arguments of substring should be "4,6".  Each of these arguments are locations; other substring functions have location and length.
I updated the filter to,
spry:test="'substring({name},4,6)'.search  ('10') != -1;"
The filter result was not changed.  Are the location arguments being ignored or overwritten by a default setting?  The symptom is that the first location is "0" and the second location is omitted.
I thank you for your help.  This is rather fascinating!
Scott
Howdy,
When you take a closer look at your at your code you will notice that you actually wrapped the substring function inside a string. So you are actually performing a search on:
'substring(contents,4,6)'
So what i would suggest is to do:
spry:test="'{name}'.substring( 4,6 ).search( '10' ) != -1 "
And if that doesn't work, try to use a function::syntax instead, see API: function::<function name>

Similar Messages

  • How to search for perticular substring in given string.

    Hi, Can any one tell me how to search for perticular substring in given string.
    example:
    I have to search for CA in given Order type it may be CA10 or CA15. Please Do the needful.

    Hi Aniruddha,
    check this...
    Data var string,
    var = 'India'.
    search var for 'Ind'.
    if sy-subrc = 0.    " var having ind
    Message 'Ind found' type 'I'.
    else  .            "var not having ind
    Message 'Ind not Found' type 'I'.
    endif.
    thanx
    bgan.

  • Looking for a substring within a string (regexp)

    Hi folks,
    I want to select a substring from a string
    string:
    21;0000;4145054;4;A;4 mit ALU XEOFX,117107,XEOFX YWY,1,YWY
    or
    21;0000;4145054;4;A;4 goldglamsnu XEOFX,198877,XEOFX YWY,1,YWY
    I'm looking for the substring:
    YWY,1,YWY
    and try this SQL statement
    SQL> select REGEXP_substr('21;0000;4145054;4;A;4 mit ALU XEOFX,117107,XEOFX YWY,1,YWY' ,',[^YWY]+[0-9]')
    2 from dual;
    REGEXP_
    ,117107
    I don't know where my mistake is. Can anybody please help me?
    Database Version 11G R2
    Thanks,
    ben
    Edited by: ben512 on May 14, 2013 5:05 PM

    Hi,
    ben512 wrote:
    Hi folks,
    I want to select a substring from a string
    string:
    21;0000;4145054;4;A;4 mit ALU XEOFX,117107,XEOFX YWY,1,YWY
    or
    21;0000;4145054;4;A;4 goldglamsnu XEOFX,198877,XEOFX YWY,1,YWY
    I'm looking for the substring:
    YWY,1,YWYWhy do you want that substring. Do you always want the last 9 characters of the string?
    If you're looking for a substring that starts with 'YWY', and then has any number (including 0) of commas, digits, and additional 'YWY' strings after it, then:
    REGEXP_SUBSTR ( str
               , 'YWY[,[:digit:]]*)
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, maybe 5 or 10 rows), and also post the results you want from that data. Include examples of any special cases you need to handle (e.g., the target pattern is not found at all, or it is found at 2 different places in the string).
    Explain, using specific examples, how you get those results from that data. Say what your business rules are.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

  • Searching for a substring within a string

    can someone reccomend a simple way to search for a substring within a string and count the number occurences of that substring.
    The substring and the string will be provided as command line parameters.
    Thanks
    gg

    A simple way would be to use the indexOf methods in String:
    http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html
    Not sure what this has to do with event handling though :-P

  • Regular expression for 2nd occurance of a substring in a string

    Hi,
    1)
    i want to find the second occurrence of a substring in a string with regular expression so that i can modify that only.
    Ex: i have a string like ---> axe,afn,sdk,jdi,afn,mki,mki
    in this i want the second occurance of afn and change that one only...
    which regular expression i have to use...
    Note that ...i have to use regular expression only....no string manipulation methods...(strictly)
    2)
    How can i apply the multiple regular expressions multiple times on a single string ..i.e in the above instance i have to apply the same 2nd occurrence logic for
    substring mki also. for this i have to use a single regular expression string that contains validations for both the sub strings mki and afn.
    Thanks in advance,
    Venkat

    javafreak666 wrote:
    Hi,
    1)
    i want to find the second occurrence of a substring in a string with regular expression so that i can modify that only.
    Ex: i have a string like ---> axe,afn,sdk,jdi,afn,mki,mki
    in this i want the second occurance of afn and change that one only...
    which regular expression i have to use...
    Note that ...i have to use regular expression only....no string manipulation methods...(strictly)
    2)
    How can i apply the multiple regular expressions multiple times on a single string ..i.e in the above instance i have to apply the same 2nd occurrence logic for
    substring mki also. for this i have to use a single regular expression string that contains validations for both the sub strings mki and afn.
    Thanks in advance,
    VenkatWhat do you mean by using a regex to get the index of a second substring? There is not method in Java which uses regex to et the index of a substring.
    There are various indexOf(...) methods for this:
    String text = "axe,afn,sdk,jdi,afn,mki,mki";
    String target = "afn";
    int second = text.indexOf(target, text.indexOf(target)+1);
    System.out.println("second="+second);Of course you can find the index of a group like this:
    Matcher m = Pattern.compile(target+".*?("+target+")").matcher(text);
    System.out.println(m.find() ? "index="+m.start(1) : "nothing found");but there is not single method that handles this: you'll have to call the find() and then the start(...) method on the Matcher instance, so the indexOf(...) approach is the favourable one, IMO.

  • Cut Substring from a string

    Hi!
    I have a question
    Can i cut a substring from a string?
    If yes how is possible?
    Can you help me with an example?
    Thanks

    Hi!
    I have a question
    Can i cut a substring from a string?Yes
    If yes how is possible?You shoould read the API for String, there is a method called substring
    Can you help me with an example?You wont need one if you read the API

  • Substr outside of string at /opt/oracle/Middleware/agent11g/EMStage/PAF/Job

    Hi,
    I have some issue while configuring the RAT(Real Application Testing), got error while preprocessing the capture workload on test database. My source target is 11.2.0.3 and destination target is 11.2.0.3.3 database. Below is the error. Below is the error from failed jobs log file.
    substr outside of string at /opt/oracle/Middleware/agent11g/EMStage/PAF/Job_CAAD88CFA1160066E0430A5108892E78_dest/untar.pl line 56.

    Google
    http://www.perlmonks.org/?node_id=572129
    http://lmgtfy.com/?q=substr+outside+of+string+at

  • How do I update the substring of a string value?

    UPDATE table1
    SET  SUBSTR  (TO_CHAR(field_value),3,2) = ' 50'  and SUBSTR (TO_CHAR(field_value),5,2)  =  '50'
    where  ( SUBSTR(TO_CHAR(field_value), 3, 2) =  '100' ) or ( SUBSTR(TO_CHAR(field_value), 5, 2) =  '100' )tried the above in TOAD and I got "ORA-00927: missing equal sign." Please help!
    data type for field_value is number. oracle version is 10g
    thank you

    Here's an example of how you can do it:
    SQL> CREATE TABLE x
      2  AS
      3  SELECT 'SOME50HERE' AS field_x
      4  FROM dual;
    Table created.
    SQL> SELECT * FROM x;
    FIELD_X
    SOME50HERE
    1 row selected.
    SQL> UPDATE x
      2  SET    field_x =  SUBSTR(field_x,1,4)
      3                 || '75'
      4                 || SUBSTR(field_x,7)
      5  ;
    1 row updated.
    SQL> SELECT * FROM x;
    FIELD_X
    SOME75HEREBasically you need to break your string into three parts:
    1. The part before the text you want to change.
    2. The text you want to change.
    3. The part after the text you want to change.
    Then you concatenate them all together.
    If #1 is not a known fixed number of characters, you can still use SUBSTR, by looking for the string you want to change like the following:
    UPDATE x
    SET    field_x =  SUBSTR(field_x,1,INSTR(field_x,'50') - 1)
                   || '75'
                   || SUBSTR(field_x,7)
    ;

  • How to extract substring from a string based on the condition ??

    Hi,
    I'm having a very large string which as below
    EQD+CN+SAMPLE18767+2200+++5'
    NAD+CA+FIR:172:20'
    DGS+IMD+3.2+2346+55:CEL'
    FTX+AAA+++GOOD'
    FTX+AAA+++ONE'
    EQD+CN+SAMPLE18795+2200+++5'
    NAD+CA+TIR:172:20'
    DGS+IMD+3.2+2346+55:CEL'
    FTX+AAA+++SECOND'
    FTX+AAA+++IS FAIR'
    similarly FTX+AAA as above and it goes on
    i tokenized each segment with delimiter as ' and able to read each segment.
    Now i want to concatenate the FTX+AAA in a single segment if more than one FTX+AAA with IMMEDIATE below
    The output is as follows
    EQD+CN+SAMPLE18767+2200+++5'
    NAD+CA+FIR:172:20'
    DGS+IMD+3.2+2346+55:CEL'
    FTX+AAA+++GOOD,ONE'
    EQD+CN+SAMPLE18795+2200+++5'
    NAD+CA+TIR:172:20'
    DGS+IMD+3.2+2346+55:CEL'
    FTX+AAA+++SECOND,IS FAIR'
    similarly FTX+AAA should be concatenated if it has similar FTX+AAA IMMEDIATE below.
    The FTX+AAA segments can come any number of times immediate below
    Please help me how we can do this??? Can anyone help me with the code snippet to do this?
    Thanks,
    Kathir

    Encephalopathic wrote:
    You've posted > 300 times here and you still don't respect the rule regarding notification of all cross-posts? [http://www.java-forums.org/advanced-java/30061-how-extract-substring-string-based-condition.html]
    Do you think this this will help convince others to help you?See also [http://www.coderanch.com/t/500088/java/java/extract-substring-string-based-condition|http://www.coderanch.com/t/500088/java/java/extract-substring-string-based-condition].

  • HOw to get  a common substring from two strings.

    Hello,
    I have a question like..how to print a common substring in to different strings.
    example: String str1="dynamic" String str2="programing" so the output for this application is "am".

    If the OP is looking for the 'longest common substring', have a look
    here for a nice explanation of Ukkonen's online suffix tree construction.
    A suffix tree is the ideal data structure for finding a LCS.
    kind regards,
    Jos

  • What's the best way to extract data (a substring) from a string?

    Hi,
    I have a field being returned from a function call and the data looks like this:
    sfaqwe4|89uuuroeoi0|kjg3j90493  (It's data...pipe...data...pipe...data)
    What is the best technique to use to extract the middle set of data between the two pipes?
    Is the any prewritten method to separate the data, or do I have to loop thru the field looking for the pipes, etc.?
    Thanks for your help,
    Andy

    <<Copy paste from http://careerabap.blogspot.com/2009_08_01_archive.html - user notified, points removed>>
    Hi,
    The WRITE statement is what we use to substring a field. The syntax is as follows:
    WRITE fieldname+starting_position(field_length) to variable
    The fieldname is the source (or input). The plus sign precedes the starting position of the substring.  The first position in the string is 0. Immediately after (no space) comes the length of the substring you are going to use. You can also substring the variable that you are writing the string to (the target).
    You can also use function module 'STRING_SPLIT_AT_POSITION'.
    Best Regards,
    Edited by: nihad omerbegovic on Dec 14, 2009 3:03 PM
    Edited by: Matt on Dec 20, 2009 4:13 PM

  • Substring using a string

    Hi, is there a way to use substring with a given string instead of an index? Something like this: String s1 contains "This a just a test". Now I need to get "just a test" into s2. The problem is that the contents of s1 is variable so I never know where "just a test" (in this example) is placed in s1.
    Roel

    Yes, that's what I want to do. I'll try to explain more clearly. I have this string that is composed like this: "2002-06-07 some info 2002-06-06 some more info 2002-06-05 ..." and so on. This is 1 long string. I need to spit that string into smaller parts so I get these strings: "2002-06-07 some info" goes into string1, "2002-06-06 some more info" into string2 and so on. That's why I want to substring it looking at the dates. Since I don't know how long "some info" is, I don't know where to find the next date.
    Roel

  • Searching for the nth occurrence of a substring in a string

    I need to search for the 63rd occurrence of a substring <i4> and replace it with <string>. Is there an easy way to do this?
    Edited by: sarcasteak on Jun 16, 2009 11:52 AM

    nevermind I got it, if anyone was curious
    int z = 0;
                   while(z<63)
                        index = index2+3;
                        index2 = result.indexOf("<param>", index);
                        resultTest = result.substring(index2);
                        //System.out.println(index2 + " :" + resultTest );
                        z++;
                   String originalSubstring = (result.substring(index2);
                   String modifiedSubstring = "";
                   modifiedSubstring = originalSubstring.replaceFirst("<i4>","<string>" );
                   modifiedSubstring = modifiedSubstring.replaceFirst("</i4>","</string>" );
                   String fixedString= result.replace(originalSubstring, modifiedSubstring);
                   System.out.println(fixedString);Edited by: sarcasteak on Jun 16, 2009 12:32 PM

  • Deleting leading substring from a string

    Hey guys,
    how can i delete a string from a leading substring?
    e.g.: "00022521" should become "22521".
    thx
    Markus

    I actually had written a little static class to handle just this.  Here is the static class.
    public class LeadingZeroRemover {
         public static String removeLeadingZeros(String str) {
              if (str == null) {
                   return null;
              char[] chars = str.toCharArray();
              int index = 0;
              for (; index < str.length(); index++) {
                   if (chars[index] != '0') {
                        break;
              return (index == 0) ? str : str.substring(index);
    Then you can simply use it like this.
    <b>LeadingZeroRemover.removeLeadingZeros</b> (soldToNumber.getValue().toString())
    Regards,
    Rich Heilman

  • File Location+Profile String

    I have a program that needs to have a specified path to a to a file every time it runs. However I don't what to have the program ask for the location of that file every time it is run. Therefore what I need to do is to figure out a way that once the location of the file has been specified (the first tiem the program is run) then it will not ask for the location of the file and read it from some specified file. I know that in C++ they are called profile strings and they use *.ini files. I didn't know if there was some sort of similar thing java or what I needed to do. I know I can make a *.ini file manually but I didn't know if there was something specifically designed to do such a thing.

    look at this http://java.sun.com/j2se/1.4.2/docs/api/java/util/Properties.html
    particularly look at the methods load and store

Maybe you are looking for

  • Mac Pro using Mac Mini as Print Server

    Hi all, Mac Pro is wired to my network, Mac Mini is Airport connected. I'd like to use Mac Mini as a Print Server without keyboard and mouse. I've installed OSXvnc-server on Mac Mini and Chicken of the VNC (CVNC) Client on Mac Pro. Mac Pro's keyboard

  • How do I let user enter a primary key value on a form

    I'm creating my first APEX application. I have a simple table called HOSTS with 2 columns HOSTNAME and IP_ADDRESS. HOSTNAME is the primary key for the table. HOSTNAME is a perfectly acceptable primary key and I don't wish to create an additional colu

  • Link between PM and HUM

    Dear all, In order to implement physical tracability on PM service orders, I need to link HU with PM. It seems that it is a standard function in PM like PP-HUM integration. Can you give me help some help on this topic ? Thanks in advance. Best regard

  • Difference between SUM values in adjoining rows

    Hi I've written following query: DECLARE @Decision_Group nvarchar(10) = 'All', @Entry_Month INT = 09, @In_Use CHAR(1) = 'Y', @Scheme nvarchar(05) = 'UGS', @Subject_Area nvarchar(10) = 'ART', @Location nvarchar(10) = 'UOB', @Home_Overseas nvarchar(05)

  • Ovi email account on X2 - 01 not responding

    Hi there. Unfortunately I cannot acces my ovi account on my cell phone. When I try to access my account, it says "application error" and then when I select the details option it says "java/lang/NullPointerExeption" I have no idea what this means. How