Testing the last character of a string using .endsWith
Hi,
I want to check to see if the last character of a string is '@'.
I tried if (StringAt.endsWith("a")) {
but got no results.
Is this the correct way to do it or is there another way.
Thanks.
Adam
javadocs:
String's endsWith method takes a string argument.
endsWith
public boolean endsWith(String suffix)
Tests if this string ends with the specified suffix.
Parameters:
suffix - the suffix.
Returns:
true if the character sequence represented by the argument is a suffix of the character sequence
represented by this object; false otherwise. Note that the result will be true if the argument is the
empty string or is equal to this String object as determined by the equals(Object) method.
Throws:
NullPointerException - if suffix is null.
Similar Messages
-
How we can find the last character in a string(Urgent Plz!)
Gurus!
How we can find the last character in a string.
e.g i have a string say "Str" with value "10-01".
Now i want to find the last character in "Str" i.e "ONE=1".
i am using Oracle developer 6i with Oracle 8i(1.7).
Plz help!
Many thanks!Use the substr() and length() functions -
x := '10-01';
y := substr(x, length(x)); -
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 ;-) -
Want to single out the last character of a string
There is a field where there are many strings of varying length. E.g.: AB001XUV, AB003XUK, DJ8933FXUV etc.
From these strings I need to create a virtual column where only the last character is shown. So it shall be V, K, V for values from the above example.
Can anyone please suggest me how to achieve this.
Regards
HawkerSQL> with t as (
2 select 'AB001XUV' col from dual
3 union
4 select 'AB003XUK' col from dual
5 union
6 select 'DJ8933FXUV' col from dual
7 )
8 select substr(col,-1,1) from t
9 /
S
V
K
V
SQL> create table temp(id number,
col varchar2(10),
VIRTUAL_COL VARCHAR2(1) GENERATED ALWAYS AS (substr(col,-1,1)) VIRTUAL
SQL> insert into temp(id,col) values(1, 'AB001XUV') ;
SQL> select * from temp ;
ID COL V
1 AB001XUV V
SQL> Edited by: Azhar Husain on Aug 16, 2011 1:17 PM -
Any easier way to replace the last character of a string?
this is what I got:
select SUBSTR('tjgb005dy_01_31_08',1,LENGTH('tjgb005dy_01_31_08')-1)||'1' from dual;
tjgb005dy_01_31_01and I am not quite fond of it. it looks ugly and it is long.
so, I wonder if you guys have better ideas?
Thanks(Perhaps with replace there is no easier solution than the primary posted.)Well, look where I ended up...
SQL> -- generating sample data:
SQL> with t as ( select 'tjgb005dy_01_31_08' str from dual union
2 select 'tjgb005dy_01_31_03' from dual union
3 select '888888888888888888' from dual
4 )
5 --
6 -- actual query
7 --
8 select str
9 , case
10 when substr(str, -1) = 8
11 then
12 substr(str, 1, length(str)-1)||'1'
13 else
14 str
15 end
16 from t;
STR CASEWHENSUBSTR(STR,-1)=8THENSU
888888888888888888 888888888888888881
tjgb005dy_01_31_03 tjgb005dy_01_31_03
tjgb005dy_01_31_08 tjgb005dy_01_31_01Now I'm going to stay at the coffee-machine for the rest of the day... ;) -
Looking for the last item in a string set in a particular character style
I should find each space that is the last character in a string set in a particular character style. For example, in the passage "123 456 789" (the underlined part here indicating a passage set in a particular character style), my ideal GREP search would yield a match after the digit 6.
How do this?Excellent! This works perfectly. I have used your string with the bold character formatting, and replaced the matches with [nothing], set in None style.
On second thought, I was surprised that it indeed had worked: why was the space replaced, and not deleted? Shouldn't I have used
(?<!.)(\s)(?=\w)
and replaced it with
$2 -
How to remove only the last element of spreadsheet string
I use path to string option to store image path into database and while retrieving the string is again converted into path but it gives out an error as the output of array to spreadsheet string gives out a tab at the end which is unable for the IMAQ read file to recognise.but when i use the path of the image directly into IMAQ readfile the image is opened . so how to remove the tab only at the end of output of the spreadsheet string(whose length can vary)? I have also attached my program with this.
Attachments:
retrieve_images_from_DB.vi 65 KB
file_path_to_db_(images).vi 40 KB
create_table_for_images.vi 45 KBindhu wrote:
> Thanks for your reply!
> But my problem is to remove only the last element(which is a tab or an
> alphabet) from a spreadsheet string of any length.
If you just want to remove the last character of a string just use the
String Size function reduce the result by one and wire it together with
the string to the Split String function.
Rolf Kalbermatter
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
Truncating last character in a string
I am making a dialpad. It is just for display so I am using a
string for the numbers selected. I am trying to make a back button
that would clear the last number added. I tried mystring.length-1
but that doesn't seem to be doing the trick. Is there a simple way
to truncate the last character in a string, of variable
length??Here's an example
var someStr="asdfasdf saf asdf sadfas dfs fsa asf";
while (someStr.length) {
someStr = someStr.substring(0,someStr.length-1)
trace(someStr);
} -
Hi Gurus,
I want to get the last character of a String.For Ex.
I have name = 'ZXCDFG":?'
And I want to print the last character ?.
How can i do it.
Thanks in Advance.Hi Pradeep,
Just find the String Length and use the offset commands
DATA : DATA TYPE CHAR20 'ABCDEFG',
DATA : DATA1,
DATA : LEN TYPE I.
LEN = STRLEN( DATA ).
LEN = LEN - 1.
DATA1 = DATA+LEN(1).
Regards
Kumar M. -
How to delete last character in a string
Guys i have a question...
how can i delete the last character in a string..
for example
String myString = "helloWorld, ";
how do i delete the last character in this string which is a "," ?String newString = myString.substring(0, myString.length()-1);
-
Strip the first character from a string
i am trying to strip the leftmost character from a string
using the following:
<cfset Charges.DTL_CHG_AMT_EDIT =
#Right(Charges.DTL_CHG_AMT_EDIT,Len(Charges.DTL_CHG_AMT_EDIT)-1)#>
i keep getting the following error:
Parameter 2 of function Right which is now -1 must be a
positive integer> RemoveChars() much easier than Right()? How so?
Semantically, if the object of the exercise is to *REMOVE
CHARacters from a
string* (which it is, in this case), it is simply better
coding to use
removeChars() rather than right(). That, and it's one less
function call
(the RIGHT() solution also requires a call to LEN() for it to
work).
So removeChars() is "easier" because it reflects the intent
of the exercise
directly, is simpler logic, is easier to read, and - I can't
be arsed
counting keystrokes - is probably less typing.
That'd be how.
Adam -
Find the last character in an aplhanumreic string
Hi guys first time poster long time hiding in the shadows,
hopefully someone can help me
I have set of username stored and I need to find the last
character before the number for example
abc123 I would want to find c
ab123 I would want to find b
any suggestions as to how I would do this?
Thanks in advanceHere's one way:
<CFSET YourString = "abc123")>
<CFSET LastChar = "">
<CFSET Pos = 1>
<CFSET CharLen = Len(YourString)>
<CFLOOP from="1" to="#CharLen#" step="1">
<CFSET Char = right(left(YourString,Pos),1)>
<CFIF Not IsNumeric(Char)>
<CFSET LastChar = Char>
<CFSET Pos = Pos + 1>
<CFELSE>
<CFBREAK>
<CFIF>
</CFLOOP> -
Deleting last character of a string
Hi Abapers,
I want to delete the last character of my workarea and then store into table.
The workarea says that it is FAX|
I have to remove the last character.
How to do tht.
Please reply.
Thankshi
do this in following way
frist find the String length
let it will be
w_str = 'sdn is wonderfull'
now use.
w_len = strlen(w_str) .
now
w_result = w_str+0(w_len - 1).
Cheers
Snehi -
Removing last character of a string
Hi Gurus,
Is there any way to remove the last character of staring other that finding the string length and doing it?
waiting for reply
RaviHI,
yaa u can do this by one logic
wht u do is concatenate one special symbol like $ to the string wht u have and in the next statement by using tht special symbol u can find fdpos i.e. field postion i.e. at which lenght it is there and then in again another statement u can increa fdpos by one and u can cut the string at tht length
i think u got my logic
further if u have any quiries u can contact me on [email protected]
plzz reward if it is usefull.... -
Select last character of a string
Hello,
I would like to select the last character of an address string. For example, in '165 John Ave W' -- select result 'W'. I tried to use RIGHT but it doesn't work. I'm using SQL Plus.
SELECT RIGHT(ADDRESS,1) FROM addresses;
ORA-00904: "RIGHT": invalid identifier
I can't find the appropriate select statement to achieve the result I want. Ideas?
Thanks!The SUBSTR function can take a negative start parameter, which counts in from the end of the string
http://www.techonthenet.com/oracle/functions/substr.php - that should get you going, let me know if you get stuck.
Carl
Maybe you are looking for
-
I have 2 iphones, 1 personal and 1 business. I thought I was supposed to have 2 separate itunes accounts. I now have a work ipad and want to only have 1 itunes account that I can use for all 3 devices. How do I cancel 1 account or just combine the
-
Multiple tables to open as 1 sheet in excel
I've built a basica depth charts to help with my fantasy football this season in numbers. Basically i have a tab with the team name then 3 tables inside of it labled offense, defense, and rookies. In numbers this opens as 1 page with 3 tables an does
-
Hi, I just created a movie in iMovie HD, but iMovie does not recognize my Pioneer 111D internal drive. I have had success burning with aftermarket software, but I can't burn from iMovie. iMovie is also looking for iDVD, which, according to Apple, req
-
Problems when updating the Intel INF file
I have the MSI 865PE Neo2-FIS2R seems every time i go through with live update and try to load the INF driver it gets started into setup and once it gets to 10% the system reboots...after several attempts to load this driver, the third time it return
-
How to install window xp in compaq presario cq60 not book
how i install window xp in compaq presario cq60 in my not book! please help me, i have trouble with vista so please sir help me. i can't find cam driver, not work properly with .net. there ar so many problame so please help me please please..........