Replace,translate or REGEXP_REPLACE
I want to remove the first character of the string that contains '~'
something like below,
FROM : ~12STRING~ABC~SOMETHING~
TO : 12STRING~ABC~SOMETHING~How do i do that, replace,translate, REGEXP_REPLACE
Please advise.
Billu
The following is slightly more performant because it doesn't have to capture (.*) and substitue (\1)It is best to provide proof when making statements that one method is better than another.
Like this;
create table source_data as (
select ' ~12STRING~ABC~SOMETHING~' c
from dual
connect by rownum <= 100000);
Table created
set timing on
create table your_regexp as (
select regexp_replace(c, '^ ?~') c
from source_data);
Table created
Executed in 0.703 seconds
create table my_regexp as (
select regexp_replace(c, '^ ?~(.*)', '\1') c
from source_data);
Table created
Executed in 1.484 secondsIt seems that you are correct. The timings differ by approx 0.1 seconds when the order of the statements is reversed.
Similar Messages
-
Encrypt/Decrypt using REPLACE/TRANSLATE function
Hi,
Can someone please provide me any procedure/function which encrypts/decrypts a string using REPLACE/TRANSLATE function?
Thanks
Dinakarexample with TRANSLATE:
CREATE OR REPLACE function temp_encrypt (p_value IN VARCHAR2)
RETURN VARCHAR2 IS
BEGIN
RETURN(TRANSLATE(p_value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'BCDEFGHIJKLMNOPQRSTUVWXYZA'));
END;
CREATE OR REPLACE function temp_decrypt (p_value IN VARCHAR2)
RETURN VARCHAR2 IS
BEGIN
RETURN(TRANSLATE(p_value, 'BCDEFGHIJKLMNOPQRSTUVWXYZA', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'));
END;
SQL> SELECT temp_decrypt('MY TEST') FROM dual;
TEMP_DECRYPT('MYTEST')
LX SDRS
SQL> SELECT temp_encrypt('LX SDRS') FROM dual;
TEMP_ENCRYPT('LXSDRS')
MY TESTyou may combine this with REPLACE() ... -
Replacing TRANSLATE with CL_ABAP_CONV_OUT_CE
Hi Gurus,
I'm working on a 4.7 version of SAP that is soon to be unicode compatible. After running UCCHECK I came accross a couple of statements I need a litle help with.
The first statement is -
TRANSLATE <data> to code page '1100'.
which I replaced with -
lcl_conv = cl_abap_conv_out_ce=>create( encoding = '1100' ).
call method lcl_conv->write( data = <data> ).
and this then lets me activate the program and removes the error when re-running UCCHECK. Can I ask is this correct?
The second statement is -
TRANSLATE i_data_tab FROM CODE PAGE gv_codepage.
How do I use the cl_abap_conv_out_ce class for this statement?
Thanks in advance,
CHi,
Please check this piece of code
DATA conv TYPE REF TO cl_abap_conv_in_ce.
DATA buffer(4) TYPE x.
DATA text(100) TYPE c.
buffer = '41424344'.
conv = cl_abap_conv_in_ce=>create(
encoding = 'UTF-8' ).
conv->convert(
EXPORTING input = buffer
IMPORTING data = text ).
write: / text.
Example for class cl_abap_conv_out_ce.
data: text(100) type c value 'ABCD',
conv type ref to cl_abap_conv_out_ce,
buffer type xstring.
conv = cl_abap_conv_out_ce=>create(
encoding = 'UTF-8'
endian = 'L'
call method conv->write( data = text n = 4 ).
buffer = conv->get_buffer( ).
write:/ buffer.
Also
you do not need to replace TRANSLATE ... TO UPPER/LOWER CASE in Unicode systems.
You just need to take care that the arguments fit:
The arguments of these instructions must be single fields of type C, N, D, T or STRING or structures of character-type only.
Regards
Hiren K.Chitalia -
Replace (translate) one char to many
I have a string. In this string i need replace all special characters (0-31 codes) with chosen representation. Representations may be of different formats. May be \x??, or \0???, or 10,13 -> \n, 9 -> \t and all others characters are converting to null. Summary - i need find all symbols with 0-31 codes and replace all of them for appropriate representation, which can be zero or more symbols.
Solution should work in 9.2 Oracle (thats mean no regexp) and shuld be very fast.
I know that TRANSLATE function is really fast. Buth there i can`t replace one symbol for many. I can replace only one by one.
My barbarian (and easy) solution is to create lists with 32 elements for each representation. Than for chosen representation make a loop over the list. Inside the loop call REPLACE function. In this case i would always call replace 32-times. I think that is expencive.
Are you have any idea?michaels2 wrote:
i need find all symbols with 0-31 codes and replace all of them for appropriate representation, which can be zero or more symbols.Then maybe sth like this:Blimey Michaels, is the XML functionality stable in 9.2 ?
I came up with this..
SQL> ed
Wrote file afiedt.buf
1 with trans_tbl as (select chr(0) as ch_frm, '#x00#' str_to from dual union all
2 select chr(1), '#x01#' from dual union all
3 select chr(2), '#x02#' from dual union all
4 select chr(3), '#x03#' from dual union all
5 select chr(4), '#x04#' from dual union all
6 select chr(5), '#x05#' from dual union all
7 select chr(6), '#x06#' from dual union all
8 select chr(7), '#x07#' from dual union all
9 select chr(8), '#x08#' from dual union all
10 select chr(9), '#x09#' from dual union all
11 select chr(10), '#x0A#' from dual union all
12 select chr(11), '#x0B#' from dual union all
13 select chr(12), '#x0C#' from dual union all
14 select chr(13), '#x0D#' from dual union all
15 select chr(14), '#x0E#' from dual union all
16 select chr(15), '#x0F#' from dual union all
17 select chr(16), '#x10#' from dual union all
18 select chr(17), '#x11#' from dual union all
19 select chr(18), '#x12#' from dual union all
20 select chr(19), '#x13#' from dual union all
21 select chr(20), '#x14#' from dual union all
22 select chr(21), '#x15#' from dual union all
23 select chr(22), '#x16#' from dual union all
24 select chr(23), '#x17#' from dual union all
25 select chr(24), '#x18#' from dual union all
26 select chr(25), '#x19#' from dual union all
27 select chr(26), '#x1A#' from dual union all
28 select chr(27), '#x1B#' from dual union all
29 select chr(28), '#x1C#' from dual union all
30 select chr(29), '#x1D#' from dual union all
31 select chr(30), '#x1E#' from dual union all
32 select chr(31), '#x1F#' from dual)
33 ,inp_str as (select 'This is '||chr(4)||' my test '||chr(29)||' string '||chr(13) as txt from dual)
34 -- END OF TEST DATA
35 select max(replace(sys_connect_by_path(ch,'`'),'`')) as txt
36 from (
37 select lvl
38 ,decode(str_to,null,substr(txt, lvl, 1),str_to) as ch
39 from inp_str cross join (select level lvl from inp_str connect by level <= length(txt))
40 left outer join trans_tbl on (ch_frm = substr(txt, lvl, 1))
41 )
42 connect by lvl = prior lvl+1
43* start with lvl = 1
SQL> /
TXT
This is #x04# my test #x1D# string #x0D#
SQL>But I don't have 9.2 to test on, so I've omitted things I know don't exist in 9.2, such as using connect_by_isleaf. -
REPLACE/TRANSLATE -- Quick Points in a hurry!!
Hey there, in a hurry here!
I'm loading a file using ws_upload and in my record which is 1000 bytes long several elements are encapsulated in " ", I need to remove them. There is only one field in the record it_upfile2-csvdata. I can easily replace all the " and not leave spaces behind. I was using search/replace in a while/endwhile loop but it appears to be looping out of control...
CLEAR flg_r.
flg_r = 'X'.
WHILE flg_r = 'X'.
SEARCH it_upfile2-csvdata FOR '"'.
IF sy-subrc = 0.
flg_r = 'X'.
REPLACE '"' WITH '' INTO it_upfile2-csvdata.
ELSE.
CLEAR flg_r.
ENDIF.
ENDWHILE.
flg_r = 'X'.
WHILE flg_r = 'X'.
SEARCH it_upfile2-csvdata FOR ' , '.
IF sy-subrc = 0.
flg_r = 'X'.
REPLACE ' , ' WITH ',' INTO it_upfile2-csvdata.
ELSE.
CLEAR flg_r.
ENDIF.
ENDWHILE.See the simple example :
CLEAR d_text1.
DO.
SEARCH in_str FOR ';'.
IF sy-subrc <> 0.
IF NOT in_str IS INITIAL.
CONCATENATE d_text1 in_str INTO d_text1.
ENDIF.
EXIT.
ENDIF.
d_position = sy-fdpos + 6.
REPLACE ';' WITH '<SUB>;' INTO in_str.
CONCATENATE d_text1 in_str(d_position)
INTO d_text1.
d_strlen = strlen( in_str ).
d_strlen = d_strlen - d_position.
IF d_strlen LT 1. EXIT. ENDIF.
in_str = in_str+d_position(d_strlen).
CLEAR d_strlen.
ENDDO. -
Replace non numerics characters with 0
Hi,
Can someone help me out with this?
I basically need to check my column value.
In case thr is an occurence of any non numeric character ,I need to replcae it with a 0.
By non numeric I mean any character other than [0-9].
For example 'rte$36^r'
I would like to convert it o '00003600'.
Thanks in advance.There are several options, like TRANSLATE or REGEXP_REPLACE (only 10g):
WITH t AS (SELECT 'rte$36^r' col1
FROM dual
SELECT t.col1
, REGEXP_REPLACE(t.col1, '[^0-9]', '0') col1_new1
, TRANSLATE(t.col1, '0123456789' || t.col1, '0123456789' || LPAD('0', LENGTH(t.col1), '0')) col1_new2
FROM t
COL1 COL1_NEW1 COL1_NEW2
rte$36^r 00003600 00003600C. -
REGEXP_REPLACE: How to use a function over the found strings?
Hello,
Consider the following:
select regexp_replace('A1BBCCA2BBCC', '(A.)', '[\1]')
from dual
'[A1]BBCC[A2]BBCC'Now I try to put a function on the replaced strings:
select regexp_replace('A1BBCCA2BBCC', '(A.)', lower('[\1]'))
from dual
'[A1]BBCC[A2]BBCC'The result is the same i.e. the function lower has been executed with my reg. expression as a parameter, not the result strings. How can I execute the function passing as a parameter not the reg. expression but the strings, that have been found? (Of course, my real need is to use a custom function, not "lower").
Thanks in advance.
Best Regards,
BeroetzI'm sure there must be a simpler way, but this is my first thought... (although strictly speaking in this example I could get rid of the lower function and just include 'a' hardcoded.)
SQL> ed
Wrote file afiedt.buf
1 with t as (select 'A1BBCCA2BBCC' as txt from dual)
2 -- end of data
3 select replace(sys_connect_by_path(lower('A'||substr(x,1,1))||substr(x,2),','),',') as x
4 from (
5 select REGEXP_SUBSTR(txt, '[^A.]+', 1, level) as x, level rn
6 from t
7 connect by level <= length(regexp_replace(txt,'[^A.]*'))
8 )
9 where connect_by_isleaf = 1
10 connect by rn = prior rn+1
11* start with rn = 1
SQL> /
X
a1BBCCa2BBCC
SQL> -
hi,
I am trying to convert the phone number like below.
(800) 523-6010 --> 8005236010
9077625100 --> 9077625100
select trim(replace(translate('9077625100',translate('9077625100','1235467890','*'),'*'),'*'))
from dual;
select trim(replace(translate('(800) 523-6010',translate('(800) 523-6010','1235467890','*'),'*'),'*'))
from dual;
select trim(replace(translate('3342796555',translate('3342796555','1235467890','*'),'*'),'*'))
from dual;when i ran the first two query its returning data correctly. but the third one not returning data. whats wrong with the query.help me on this. same query only i am using.
Edited by: Vi on Jul 25, 2012 10:26 PMVi wrote:
I need to translate if the phone number is in both format to normal number
(334) 279-6555
3342796555
Edited by: Vi on Jul 25, 2012 10:43 PMJust don't think that when you get there what you have is a number -- don't store it in a column defined as numeric data type. In spite of what it looks like, in spite of the fact that it is (in this era) represented with nothing but numeric characters, it is NOT truely a number - it is just a character string. And so it should be stored in a varchar2.
If you choose to ignore this advice you will be back here very soon asking why the telephone "number " 0417893187 is missing the leading zero. -
Find and replacing special characters
we have just discovered that after database unicode conversion, some special characters are starting to appear in the database after users copy and paste into the database.
For example from a table, we can identify it with:
SQL> select count(*) from table where column_name like '%' || chr(25) || '%';
COUNT(*)
15
This is for a table.
How can this be done to identify the characters for all tables because we are not sure of all the tables
ThanksHi,
Please try below pl/sql block to identify special characters in tables with respect to columns
set serveroutput on size 1000000
declare
procedure gooey(v_table varchar2, v_column varchar2) is
type t_id is table of number;
type t_dump is table of varchar2(20000);
type t_data is table of varchar2(20000);
l_id t_id;
l_data t_data;
l_dump t_dump;
cursor a is
select distinct column_name
from dba_tab_columns
where table_name = v_table
and data_type = 'VARCHAR2'
and column_name not in ('CUSTOMER_KEY','ADDRESS_KEY');
begin
for x in a loop
l_id := null;
l_data := null;
l_dump := null;
execute immediate 'SELECT ' || v_column || ', ' || x.column_name || ', ' ||
'dump(' || x.column_name || ')'
|| ' FROM ' || v_table
|| ' WHERE RTRIM((LTRIM(REPLACE(TRANSLATE(' || x.column_name ||
',''ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@#$%^&*()_+
-=,!\`~{}./?:";''''[ ]'',''A''), ''A'', '''')))) IS NOT NULL'
bulk collect into l_id, l_data, l_dump;
if l_id is not null then
for k in 1..l_id.count loop
dbms_output.put_line(v_table || ' - ' || x.column_name || ' - ' ||
to_char(l_id(k),'999999999999'));
dbms_output.put_line(l_data(k));
dbms_output.put_line(l_dump(k));
dbms_output.put_line('*********************');
end loop;
end if;
end loop;
end gooey;
begin
gooey('table1','coln1');
gooey('table1','coln2');
gooey('table2','coln3');
end;
Like this you can get special characters for all the columns/particular column from table
Thanks,
Nitin -
Removing more than one underscore in a string
Hi All,
i have column called tax_name, it stores the values as
1. 'Service @ 5 %'
2. 'Service Tax - Consulting Services' etc..
using RTRIM(LTRIM(SUBSTRB(REPLACE(TRANSLATE (
i have converted them to Service__5_Amt, Service_Tax__Consulting_Amt etc.. using
Now how to remove more than one underscore from above literals.
There may be many underscores consecutively due to the conversion of wild characters into underscores.
if there are three wild characters continously there will be three underscores. So i want remove those and put only 1 underscore.Or
SQL> with t as (
select 'Service__5_Amt, Service_Tax__Consulting_Amt etc..' str from dual
select str, regexp_replace(str,'_{2,}', '_') str2 from t
STR STR2
Service__5_Amt, Service_Tax__Consulting_Amt etc.. Service_5_Amt, Service_Tax_Consulting_Amt etc..
1 row selected. -
Logic for correcting strings with different barckets
can any one tell me the simple logic for correcting strings with different barckets
suppose say for eg.
(<{abc}>defgh) should evaluate to TRUE
(<{abc>} should evaluate to FALSE
Things to check is
1. number of opening brace and closing brace
2. Their position are correct or not
If the above two conditions are met than it is TRUE else FALSE
i guess string function with decode and lenght function or case should do but bit difficult to develop this logic in with sql
Thanks,
AAKHi,
Here is non REGEXP_REPLACE version ( Unfotunately dont have 10G to feel the power of REGEXP_REPLACE.
SQL> ed
Wrote file afiedt.buf
1 SELECT DECODE(SUM(CASE
2 WHEN Left = '(' AND Right =')' THEN 0+Count_Bracket
3 WHEN Left = '<' AND Right ='>' THEN 0+Count_Bracket
4 WHEN Left = '{' AND Right ='}' THEN 0+Count_Bracket
5 WHEN Left = '[' AND Right =']' THEN 0+Count_Bracket
6 ELSE
7 1
8 END
9 )
10 ,0,'Valid','Invalid')
11 FROM
12 (
13 SELECT SUBSTR(str,(len+1 - level),1) Left, SUBSTR(str,(len + level),1) Right, MOD(LENGTH(str),2)
14 FROM
15 (
16 SELECT
17 REPLACE(translate('&exp','abcdefgh',' '),' ') str,
18 LENGTH(REPLACE(translate('&exp','abcdefgh',' '),' '))/2 len
19 FROM DUAL
20 )
21 CONNECT BY LEVEL <= LEN
22* )
SQL> /
Enter value for exp: (<{abc>} )
old 17: REPLACE(translate('&exp','abcdefgh',' '),' ') str,
new 17: REPLACE(translate('(<{abc>} )','abcdefgh',' '),' ') str,
Enter value for exp: (<{abc>} )
old 18: LENGTH(REPLACE(translate('&exp','abcdefgh',' '),' '))/2 len
new 18: LENGTH(REPLACE(translate('(<{abc>} )','abcdefgh',' '),' '))/2 len
DECODE(
Invalid
SQL>
SQL> /
Enter value for exp: <{[()]}>
old 17: REPLACE(translate('&exp','abcdefgh',' '),' ') str,
new 17: REPLACE(translate('<{[()]}>','abcdefgh',' '),' ') str,
Enter value for exp: <{[()]}>
old 18: LENGTH(REPLACE(translate('&exp','abcdefgh',' '),' '))/2 len
new 18: LENGTH(REPLACE(translate('<{[()]}>','abcdefgh',' '),' '))/2 len
DECODE(
Valid
SQL>
SQL> /
Enter value for exp: ([{<>}])
old 17: REPLACE(translate('&exp','abcdefgh',' '),' ') str,
new 17: REPLACE(translate('([{<>}])','abcdefgh',' '),' ') str,
Enter value for exp: ([{<>}])
old 18: LENGTH(REPLACE(translate('&exp','abcdefgh',' '),' '))/2 len
new 18: LENGTH(REPLACE(translate('([{<>}])','abcdefgh',' '),' '))/2 len
DECODE(
Valid
SQL>
SQL> /
Enter value for exp: (<{abc}>defgh)
old 17: REPLACE(translate('&exp','abcdefgh',' '),' ') str,
new 17: REPLACE(translate('(<{abc}>defgh)','abcdefgh',' '),' ') str,
Enter value for exp: (<{abc}>defgh)
old 18: LENGTH(REPLACE(translate('&exp','abcdefgh',' '),' '))/2 len
new 18: LENGTH(REPLACE(translate('(<{abc}>defgh)','abcdefgh',' '),' '))/2 len
DECODE(
Valid
SQL> Note: Only thing needs to care is " translate('<{[()]}>','abcdefgh',' ') " if string has some additional characters please include here.
Regards -
Need to update a column - Remove some values.
Hi,
I have a table with say two columns
TEST(a number, b VARCHAR2(3000))
The record is like
1, 'abv,ced,efer,drt,s,uywe,rerer,swewe,dfx,werrr,qwe,'
I need to remove all those from the column value which match to following list
'abv','drt','dfx'
Such that the table shud have
1,'ced,efer,s,uywe,rerer,swewe,werrr,qwe,' as its values
I am using Oracle 10G .
Nested Replace/Translate is an option But wanted to know a better way .:)Solomon's query
SQL>with t as (
2 select 'abv,efer,,,,s,uywe,abv,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx,' col from dual union all
3 select 'abv,efer,,,,s,uywe,abv,,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx,' col from dual
4 )
5 select col, regexp_replace(regexp_replace(',' || col || ',','(,?(abv|drt|dfx),?)+',','),'(^,)|(,$)') newstr
6 from t;
COL NEWSTR
abv,efer,,,,s,uywe,abv,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx, efer,,,,s,uywe,ced,rerer,swewe,werrr,qwe,
abv,efer,,,,s,uywe,abv,,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx, efer,,,,s,uywe,ced,rerer,swewe,werrr,qwe,A slight variants of his, with no nested REGEXP_REPLACE
SQL>with t as (
2 select 'abv,efer,,,,s,uywe,abv,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx,' col from dual union all
3 select 'abv,efer,,,,s,uywe,abv,,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx,' col from dual
4 )
5 select col, trim(',' from regexp_replace(',' || col || ',','(,?(abv|drt|dfx),?)+',',')) newstr
6 from t;
COL NEWSTR
abv,efer,,,,s,uywe,abv,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx, efer,,,,s,uywe,ced,rerer,swewe,werrr,qwe
abv,efer,,,,s,uywe,abv,,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx, efer,,,,s,uywe,ced,rerer,swewe,werrr,qwe
SQL>
SQL>with t as (
2 select 'abv,efer,,,,s,uywe,abv,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx,' col from dual union all
3 select 'abv,efer,,,,s,uywe,abv,,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx,' col from dual
4 )
5 select col, regexp_replace(col,',?(abv|drt|dfx),?') newstr
6 from t;
COL NEWSTR
abv,efer,,,,s,uywe,abv,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx, efer,,,,s,uyweced,rerer,swewe,werrr,qwe
abv,efer,,,,s,uywe,abv,,drt,dfx,ced,rerer,swewe,werrr,qwe,dfx,dfx,dfx, efer,,,,s,uyweced,rerer,swewe,werrr,qwe -
Loop over a list of string separated by ;
Hello,
i have a list of string in a varchar2 separated by ;
i wanna make a loop over this list and extract all string inside
any one has an idea ?
Thanks
Regards
Sallemeluser10393090 wrote:
Hello,
i tried it, i got this error :
PL/SQL: ORA-00904: "REGEXP_REPLACE": invalid identifierWell we have to assume you've got 10g or 11g unless you specify otherwise as lower versions are unsupported.
SQL> select substr( the_string
2 , decode( level, 1, 1, instr(the_string,',',1,level-1)+1)
3 , decode( instr(the_string,',',1,level), 0, length(the_string), instr(the_string,',',1,level) - decode( level, 1, 0, instr(the_string,',',1,level-1))-1)
4 ) the_value
5 from ( select '10,12,20,30,30,3,12,12,56' the_string
6 from dual
7 )
8 connect by level < length(replace(translate(the_string,'01234567890','00000000000'),'0')) + 2;
THE_VALUE
10
12
20
30
30
3
12
12
56
9 rows selected.
SQL> -
Hi,
I have a string "International Business Machine", but I want to refer as IBM (not as International Business Machine), So how do I get this value from my string. Is there any standard procedure/function available..
I want OCP from the strin 'Oracle Certified Professional'
Thanks,
GladsonHello,
If you happen to be on Oracle 10g you could use regular expressions. This extracts all capital letters regardless of location:
SELECT REGEXP_REPLACE('Oracle Certified Professional', '[^A-Z]') from dual
--> OCP
If you are pre-10g there are a bunch of ways to do this, I quite like this approach:
SELECT REPLACE(TRANSLATE('Oracle Certified Professional', LOWER('Oracle Certified Professional'), 'x'), 'x') from dual;
--> OCP
If your goal is to extract initial letters regardless of case you could use INITCAP around your source string.
The real answer depends on what your specification is but this should at least get you thinking about it.
Good Luck. -
How to take the values from a String ( CSV values).
Hi All,
I am passing csv String to a procedure as in parameter,but I have to take the values from a csv String one by one.Please let me know Is there any StringTokenizer function in oracle to take values like in java. Here is my javacode.
import java.util.StringTokenizer;
public class Sample {
public static void main(String[] args) {
String s="one,two,three,four,five";
StringTokenizer stringTokenizer=new StringTokenizer(s,",");
System.out.println( stringTokenizer.countTokens());
System.out.println(stringTokenizer.hasMoreTokens());
while(stringTokenizer.hasMoreTokens()){
System.out.print(stringTokenizer.nextToken());
o/p: one two three four fiveSomething based around one of these two methods should assist...
select substr( the_string
, decode( level, 1, 1, instr(the_string,',',1,level-1)+1)
, decode( instr(the_string,',',1,level), 0, length(the_string), instr(the_string,',',1,level) - decode( level, 1, 0, instr(the_string,',',1,level-1))-1)
) the_value
from ( select '10,12,20,30,30,3,12,12,56' the_string
from dual
connect by level < length(replace(translate(the_string,'01234567890','00000000000'),'0')) + 2
or
SQL> select REGEXP_SUBSTR ('a,b,c,d,e', '[^,]+', 1, level) from dual connect by level<=5
2 /
REGEXP_SU
a
b
c
d
e
SQL>
Maybe you are looking for
-
Connecting iPhone4 (iOS 7.1.1) with iTunes 10.6.3
Trying to connect and sync my iPhone4 with iTunes, it tells me I would need iTunes 11.1. or later. But this again requires Mac OSX 10.6.8. while my MacBook runs OSX 10.5.8. Do I really have to buy a new OSX-Version for my Mac in order to sync my iPho
-
Windows OracleOraDb11g_home1TNSListener TNSTNS-12541
I have set the "Startup" Type for "OracleOraDb11g_home1TNSListener" service to "Manual" and when I try to start it, I get a pop-up saying: "The OracleOraDb11g_home1TNSListener service on Local Computer started and then stopped. Some services stop aut
-
Flipping a chart so the low numbers are at the top...
How do I create a chart that shows the low numbers on top? I'm trying to show the rank of items over time, with lower numbers being higher in rank...
-
How to see top liked content for different period?
On any space you can only see top liked content for one month. What if I want to see top liked content for whole year or for 2 years? Is there any option where I can choose? Some contents are very useful but they got lost in all other discussions.
-
Problem pasting artwork direct from AI
Hi, I am new to InDesign from Quark . Absolutely loving the workflow in InDesign. Making my life much easier! I understand that you can paste elements directly from AI into InDesign and that it embeds then rather than links them. This works fine howe