Re: Trying to trim a string using java

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Trying to trim a string using java

Bhavin Shah
Hello All,

I am getting an error, kindly help me how to resolve it. (Attached)


Thanks

On Monday, July 2, 2012 at 6:04:02 PM UTC+5:30, cevon carver wrote:
Hello, I am trying to trim a text message so i can compare two strings together. I am able to get the text from the id but i'm not certain how selenium syntax needs to be in java to remove certain string values. What i am trying to do is find the "-" index and erase everything after it.
 to help here is the code
<tr>
 <td>storeText</td>
 <td>id=gwt-debug-ticket_list[1][ID]</td>
 <td>CsDate</td>
        <td>string d = ${CsDate}<td>
        <td> ${CsDate} = d.indexOf('-');</td>
       // <td>d.(2);</td>
       // <td> ${CsDate} = d </td>
        <td>CsDate</td>  
</tr>
<tr>
 <td>echo</td>


The string id 20120712-0032

I am trying to get everything before the"-" but not sure how to get rid of the numbers after. 
 <td>${CsDate}</td>
 <td></td>
[6/29/2012 2:29:27 PM] Cevon  Carver: what i am trying to do is to find the index of '-' from 20120628-00055. After finding the index, i want to keep everything before '-' and delete everything after
[6/29/2012 2:29:31 PM] Cevon  Carver: Thank You in advance

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/714a6e4c-bc30-4713-a352-9ff135f6f144%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

str error.jpg (30K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Trying to trim a string using java

Reed Xia
If your question is: Given String str = " 20120712-0032 ", how to make str = " 20120712".

You may want to try:

String s = "14.015_AUDI";
String[] parts = s.split("_"); //returns an array with the 2 parts
String firstPart = parts[0]; //14.015
See https://stackoverflow.com/questions/12130776/slice-string-in-java?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

On Fri, Jun 8, 2018 at 2:24 PM, Bhavin Shah <[hidden email]> wrote:
Hello All,

I am getting an error, kindly help me how to resolve it. (Attached)


Thanks

On Monday, July 2, 2012 at 6:04:02 PM UTC+5:30, cevon carver wrote:
Hello, I am trying to trim a text message so i can compare two strings together. I am able to get the text from the id but i'm not certain how selenium syntax needs to be in java to remove certain string values. What i am trying to do is find the "-" index and erase everything after it.
 to help here is the code
<tr>
 <td>storeText</td>
 <td>id=gwt-debug-ticket_list[1][ID]</td>
 <td>CsDate</td>
        <td>string d = ${CsDate}<td>
        <td> ${CsDate} = d.indexOf('-');</td>
       // <td>d.(2);</td>
       // <td> ${CsDate} = d </td>
        <td>CsDate</td>  
</tr>
<tr>
 <td>echo</td>


The string id 20120712-0032

I am trying to get everything before the"-" but not sure how to get rid of the numbers after. 
 <td>${CsDate}</td>
 <td></td>
[6/29/2012 2:29:27 PM] Cevon  Carver: what i am trying to do is to find the index of '-' from 20120628-00055. After finding the index, i want to keep everything before '-' and delete everything after
[6/29/2012 2:29:31 PM] Cevon  Carver: Thank You in advance

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/714a6e4c-bc30-4713-a352-9ff135f6f144%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAB_-H0_0JxJEHkRMfYuEp5VHY0EGBf1sZjwb9-XxFNCVVvroCg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.