Finding last char in the string
Hi
i need to find out whether the last char of a string is '/' (forward slash). please let me know if there's a FM to do that. Other post me the logic for this ASAP.
thanks
len = strlen(char).
len = len - 1.
if char+len(1) = '/'.
*write ur code
endif.
chk this code
REPORT ychatest.
DATA : str(5) VALUE '123/',
len TYPE i.
len = STRLEN( str ).
len = len - 1.
IF str+len(1) = '/'.
WRITE : '/ found'.
ENDIF.
<b>Reward points if helpful and close thrad if solved</b>
Message was edited by: Chandrasekhar Jagarlamudi
Similar Messages
-
Deleting last char in a string...
I have a string that is created as follows: strBuffer += k.getKeyChar();(k is KeyPressed ...KeyEvent) How can I delete the last Char in the string strBuffer?
Hi
// simply substring
if (strBuffer.length() > 1)
strBuffer = strBuffer.substring(0, strBuffer.length()-1);
// you may also use
if (strBuffer.length() > 1)
StringBuffer buffer = new StringBuffer(strBuffer).
deleteCharAt(strBuffer.length()-1);
strBuffer = buffer.toString();
}I've not tested the above code myself & I've written the above code on the go after reading your query. The above code definitely work & help you.
Regards,
JPassion -
How to delete the last char in a String?
i want to delete the last char in a String, but i don't want to convert the String to a StringBuffer or an array, who knows how to do?
Try it in this way
String MyString = "ABCDEF";
MyString = MyString.substring(0,MyString.length()-1); -
Deleting the last char of a string
How can I Delete the last char of a string???
example:
asd@fdg@vvdfgfd@gdgdfgfd@gdfgdf@
I want delete the last @!
Tks in advance!hi,
try this:
lv_count = strlen(string).
lv_count_last = lv-count - 1.
replace string+lv_count_last(lv_count) in string by ' '.
This should work.
thnx,
ags.
Edited by: Agasti Kale on Jun 4, 2008 9:03 PM -
hello experts
I have a scenario RFC2WS and sending
<?xml version="1.0" encoding="UTF-8" ?>
- <rfc:ZRFC_POLICY_OR_INSURANCE xmlns:rfc="urn:sap-com:document:sap:rfc:functions">
<PASSWORD>kf001</PASSWORD>
<USERNAME>kfirg001</USERNAME>
</rfc:ZRFC_POLICY_OR_INSURANCE>
but in the XI I am recieving
<?xml version="1.0" encoding="UTF-8" ?>
- <rfc:ZRFC_POLICY_OR_INSURANCE xmlns:rfc="urn:sap-com:document:sap:rfc:functions">
<PASSWORD>kf00</PASSWORD>
<USERNAME>kfirg00</USERNAME>
</rfc:ZRFC_POLICY_OR_INSURANCE>
it is always cutting the last char in the username\password. in the RFC it is defined as a String.
I couldnt find out why it is cutting the last char and help would be great.
Thanks
KfirHi,
Is it possible for you to send it with Filed type as CHAR instead of String..
In RFC source code you could handle this kind of conversion.
Try with CHAR...instead of string.
Thanks
Swarup -
How to remove last char in a string by space
I have to implement backspace application(remove a last char in a string , when we pressed a button).
for ex: I enter the no
1234
instead of 1236
So when i press a button on the JWindow... it should display
123
so that i can enter 6 now.
I tried to display the string "123 " instead over "1234" but it is not working when the no background is specified. but works fine when a background color is specified.
The string is displayed as
Graphics2D g = (Graphics2D)window.getGraphics();
AttributedString as = new AttributedString(string, map);
g.drawString(as.getIterator(),x,y);
In the map, the background is set to NO_BACKGROUND.
Thanks and regardsDeja vu. I saw this kind of post before, and I'm sure
it was today.http://forum.java.sun.com/thread.jspa?threadID=588110&tstart=0
Here it is. -
Compare the last Char to the First Char in a Sting
Hello, this should be easy but I'm having problems so here goes.
I get the user to input a Stirng and I want it to compare the last Char to the first Char. I have writen this but StartWith can take a Char?
public static void main(String[] args) {
// TODO code application logic here
String strA = new String();
int length = 0;
char lastLetter;
System.out.println("Please input your first String: ");
strA = EasyIn.getString();
length = strA.length()-1;
lastLetter = strA.charAt(length);
if( strA.endsWith(lastLetter))
System.out.println("The first letter matches the last");
else
System.out.println("They Don't match");
}I have tried lastLetter.endsWith(strA) but that dosn't work some thing to do with it not taking Char
From reading you can go strA.startWith("R") and that would look for R but you can't put a char in that would be a single letter.
I also tried to lastletter to a string but then charAt wouldn't work.fixed it I used substring as its a string object any one recomend a better way let me know
public static void main(String[] args) {
// TODO code application logic here
String strA = new String();
int length = 0;
String lastLetter;
System.out.println("Please input your first String: ");
strA = EasyIn.getString();
length = strA.length()-1;
lastLetter = strA.substring(length);
if( strA.startsWith(lastLetter))
System.out.println("The first letter matches the last");
else
System.out.println("They Don't match");
} -
I have the following code that functions like a basic RPN calculator:
public class Main {
* @param args the command line arguments
static public ArrayList<Double> stack = new ArrayList<Double>();
static double numberInput;
static double answer;
static String operation;
//Prints Welcome screen, initialized checkforInput
public static void main(String[] args) {
System.out.println();
System.out.println("Welcome to RPNCalc by theCoffeeShop()");
checkForInput();
//Checks for input, redirects to appropriate method
public static void checkForInput() {
Scanner reader = new Scanner(System.in);
String input = reader.nextLine();
if(isDouble(input) == true) {
double number = Double.parseDouble( input );
stack.add(0, number);
repeat();
} else {
operation = input;
operation();
//Processes numeric operations
public static void operation () {
if(operation.equals("+")) {
answer = stack.get(1)+stack.get(0);
stack.add(0, answer);
System.out.println(answer);
repeat();
} else if (operation.equals("-")) {
answer = stack.get(1)-stack.get(0);
stack.add(0, answer);
System.out.println(answer);
repeat();
} else if (operation.equals("*")) {
answer = stack.get(1)*stack.get(0);
stack.add(0, answer);
System.out.println(answer);
repeat();
} else if (operation.equals("/")) {
answer = stack.get(1)/stack.get(0);
stack.add(0, answer);
System.out.println(answer);
repeat();
} else {
System.out.println("Incompatible operation");
repeat();
//Called when ready to recheck for input
public static void repeat() {
checkForInput();
//Checks if string is double
public static boolean isDouble( String input )
try
Double.parseDouble( input );
return true;
catch(Exception e)
return false;
}To perform a basic operation (5+2), you would do the following
5
enter
2
enter
(plus)
enter
Computer prints 7.
I would like it to function like this:
5
enter
2(plus)
enter
Computer prints 7.
To do this, I have to be a be to split a string into 2 parts, the operation and the number. I think I could do this with a StringBuffer, but How to read the LAST char of a StringBuffer, instead of just a specific char? If there is a way to do it w/out a StringBuffer, I'm open to suggestions.Hint:
The last character of a String (or StringBuilder or StringBuffer, etc.) is at the index (length_of_string - 1).
Are you sure you're supposed to solve the problem this way? Usually homework assignments of this sort involve writing a whole parser. -
How to find last date of the current year
Hi
Please tell me is there any function module to find out the last date of the current year.Hi,
You can do that very simply like so.
code
report zrich_0001.
data: first type sy-datum.
data: last type sy-datum.
first = sy-datum.
first+4(4) = '0101'.
last = sy-datum.
last+4(4) = '1231'.
write:/ first, last.
[/code]
OR use function modules
1.use this function module HR_GB_TAX_YEAR_DATES
Pass these values
P08_TXYEAR = Year
P08_PAYROLL_AREA = '01'
2.use FM......... FIRST_AND_LAST_DAY_IN_YEAR_GET
DATA: first LIKE sy-datum,
last LIKE sy-datum.
CALL FUNCTION 'FIRST_AND_LAST_DAY_IN_YEAR_GET'
EXPORTING
i_gjahr = '2007'
i_periv = '24'
IMPORTING
e_first_day = first
e_last_day = last.
WRITE: / 'First Date', first, ' Last Date', last.
Regards,
Raj. -
I am trying to get last day of the year, is oracle provide any inbuilt function to get this otherwise I am using the below mention query is fine.
select last_day(to_date('01'||'/'||'12'||'/'||to_char(sysdate,'YYYY'),'DD/MM/YYYY')) from dual
Thx
Shishu PaulHi!
I would prefer using
select to_date('31'||'/'||'12'||'/'||to_char(sysdate,'YYYY')) from dual;
since it is not likely that the last day of any year in near future will be anything else than December 31st.
Regards,
Petra -
How can i Omit the chars in the string
Hi Gurus,
I have a input variable, assume that in that variable the value is like CAD0586/08 or BR80195/08.
my requirement is i have a new variable in that the value should be, starting alphabets should be omitted in the above variable.
ie
my input value is like var1 = CAD0586/08 or BR80195/08
my output should be
var 2 = 0586/08 or 80195/08
i have to perform this in SAP script. what is the logic for this.
regards,
LakshminarayanaHi ,
data : var1 type c, (give a specified length)
var2 type i,
var3 type i
*Make a range table(r_tab) , contain the digit from 0 to 9 .
w_tab-low = '0'
w_tab-sign = 'I'
w_tab-option = 'BT'
w_tab-high = '9'.
append w_tab to r_tab.
var2 = strlen (var1).
do var2 times.
if var2+0(var3) not in r_tab
continue.
var3 = var3 + 1.
endif.
enddo
now take offset of var1 from position at var3.
var4 = var1+var3(var2).
Thanks
shambhu
Edited by: shambhu sharan pandey on Oct 27, 2009 7:16 AM -
Ok i am trying to make just a simple calculator program for a class. I am trying to get the backspace button to work. How would i delete the last char in the string.
use a substring, the last char. will be:
myString.length
that will give you the length and from that you know what the last char. is -
Hi Guys
How can I remove the last char of a String ?With [the substring method|http://java.sun.com/javase/6/docs/api/java/lang/String.html#substring(int,%20int)] .
-
Hi,
In C there is a function strchr() to find a char in a string. Is there an equivalent funtion in Java?
The function indexOf() returns an int, but I want this char search would return a boolean value.
So help please, thanks a lot
chanhpublic boolean strchr(char myChar, String myString){
for(int j = 0; j < myString.length(); j++){
if(myChar == myString.charAt(j) return true;
return false;
}Is this what you are looking for? -
The last character of a string
How to judge the last char of a string is " ?
if (s.endsWith("""))or
if (s.endsWith("/""))bet
you just copied and pasted what the OP had written
and quickly put that
backslash in, hit post without previewing first just
to make me look like
a slow old sod! It's not fair ;-)
kind regards,
JosNope, I used the Alt-[numeric code] combinations to manually type each character. Cut-n-paste is for wimps, and actually typing single-stroke keys is for milquetoasts.
Alt-[numeric code] is for real men ;-)
Maybe you are looking for
-
Dynamically re-render cells with event in another cell
Dear all, I have a JTable that uses the default cellrenderer, it has two checkboxes, one of which disables the entire row, except for itself, so the row can be re-enabled. However, I want to be able to color in the row Color.GRAY or some other suitab
-
Bonjour je Vient d'acheter un iPhone 4s 8GB d'occasion Il était bloquer sfr je ai été voir sur le site il parlait de la restauration elle etait impossible a faire puisqu'il y avait un compte iCloud Enregistrer j'ai été été voir sur Internet commen
-
Connecting iPad + iPhone to the Internet 101
Sorry for the simple question, but I've received conflicting information from Verizon and AT&T and have seen and hear more conflicting information on the Internet, from various people, etc. Let me start from the beginning... I currently have an aging
-
Bandwidth requirement for Storage over WAN
Working on a project for storing data across geographically dispersed locations, I need to be able to estimate how much bandwidth that will be required to do remote mirroring. I assume the initial data has been loaded on my backup servers at the 2 lo
-
I have a webpage up with this function: <script language=javascript> function UI3_DoFSCommand( command, args ) { if(command == "window") alert(args); window.open( args , "_blank", "menubar=0,resizable=0,width=800,height=800" ); </script> My question