Finding last index of a string in Oracle
Use -1 as the start position:
INSTR('JD-EQ-0001', '-', -1)
How to read string from right PLSQL
substr('DV-2011-01-000004', length('DV-2011-01-000004')-6 + 1 )
Extract number from string with Oracle function
You'd use REGEXP_REPLACE
in order to remove all non-digit characters from a string:
select regexp_replace(column_name, '[^0-9]', '')
from mytable;
or
select regexp_replace(column_name, '[^[:digit:]]', '')
from mytable;
Of course you can write a function extract_number
. It seems a bit like overkill though, to write a funtion that consists of only one function call itself.
create function extract_number(in_number varchar2) return varchar2 is
begin
return regexp_replace(in_number, '[^[:digit:]]', '');
end;
Remove last character from string in sql plus
A closing parenthesis is in the wrong place. It should be:
SUBSTR(ooo.CO_NAME, 1, LENGTH(ooo.CO_NAME) - 1)
Java: Get last element after split
Save the array in a local variable and use the array's length
field to find its length. Subtract one to account for it being 0-based:
String[] bits = one.split("-");
String lastOne = bits[bits.length-1];
Caveat emptor: if the original string is composed of only the separator, for example "-"
or "---"
, bits.length
will be 0 and this will throw an ArrayIndexOutOfBoundsException. Example: https://onlinegdb.com/r1M-TJkZ8
Related Topics
Have Pl/Sql Outputs in Real Time
Good Embedded Database Solution (Like Sqlite) for .Net
Round Date to 10 Minutes Interval
Update All SQL Null Values in Multiple Columns Using Column Level Where Clause
Oracle SQL Query for Records with Timestamp That Falls Between Two Timestamps
Issue of Multiple SQL Notifications in ASP.NET Web Application on Page Refresh
Sql Dynamic Order by Using Alias
Finding The Decade with Largest Records, SQL Server
Sql Server Freetext Match - How to Sort by Relevance
Insert Large Amount of Data Efficiently with Sql
Merge Two Tables/Concatenate Values into Single Column
Why Doesn't Oracle Allow Consecutive Newline Characters in Commands
Postgresql Error: 42P01: Relation "[Table]" Does Not Exist
Sqlite: Autoincrement Primary Key Questions