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.
Similar Messages
-
How to replace one char with two chars in email address policy?
I very much like to replace the 'ß' char in the surname with 'sz'. However, applying filter '%rßsz%[email protected]' on 'Preußig' leaves me with '[email protected]'.
So, how do I replace one char with two chars in email address policy?As far as I know, your only solution is to manually create such addresses instead of using e-mail address policy.
Ed Crowley MVP "There are seldom good technological solutions to behavioral problems." -
JTextArea and typing one char at a time!
Hi everyone!
I'm developing an small app. In certain cases, the user may want to edit a little piece of text. For this, I show a new Frame with a JTextArea with the selected text, so the user can edit it...
But I want to control this edition: the user only can type one char at a time, disable selecting text and waiting a short time (250ms) between char and char...
Some ideas? Some suggestion?
Should I use keylistener and wait for the KeyPressed event and wait inside 250 ms?
The reason for the waiting: when the user type a new char (or delete an existing one), I need to do some calculations. And it must be char by char, if the user select text and replace it, or if the user type fast... my program crash.
Thanks in advance!Use a DocumentFilter and add the character yourself one at a time.
Or better perform the calculation there.
http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html#filter
Also perform the calculation in the Event Dispatch Thread so it will wait until the calculation is finished before accepting new input. -
Non-.CSV format: expand data from one cell to many
I would like to expand this data from one cell to many where each space is the delineator as well as the /slash.
Example data:
Mr. Bernardo Mestido/Portugal
Ms. Renata Sateel/Germany
-Thank you for any help!Here is a simple script which does the trick :
--{code}
--[SCRIPT exploder ]
Yvan KOENIG (VALLAURIS, France)
2011/09/19
on run
Here the clipboard contains the datas to 'explode' *)
my remplace(the clipboard as text, space, tab)
set the clipboard to my remplace(result, "/", tab)
Now you may paste in a table *)
end run
--=====
replaces every occurences of d1 by d2 in the text t
on remplace(t, d1, d2)
local oTIDs, l
set oTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to d1
set l to text items of t
set AppleScript's text item delimiters to d2
set t to l as text
set AppleScript's text item delimiters to oTIDs
return t
end remplace
--=====
--[/SCRIPT]
--{code}
Yvan KOENIG (VALLAURIS, France) lundi 19 septembre 2011 23:06:15
iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0
My iDisk is : <http://public.me.com/koenigyvan>
Please : Search for questions similar to your own before submitting them to the community -
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.
BilluThe 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. -
I want to open a folder in a separate window by clicking on it. For some reason when I click on a folder it just replaces the one I was just in. I want them both to be open at the same time without having to go through several steps. Old apple operating systems made it easy to have several folders open at one time.
Eric, thanks that works but seems like an extra added step also to do it that way. I've got to move and organize a ton of files and I'm looking for a easy way to get this done. I could also open the folder into a separate tab and then drag the tab out so it becomes an open window but thats a lot of fussing around also with extra steps. Not sure why these newer operating system seems more confusing and less user friendly than what they used to. In the past I could just click on any folder and it would open in a separate window making it really easy to copy or move files from one place to the other just by simply dragging them from one window to the other. Seems like I'm going through several extra steps now to do a simple task.
-
I cannot get my new 4th generation shuttle to sync. It says it is but it doesnt. This is a replacement for one that is lost
I cannot get my new 4th generation shuttle to sync. It says it is but it doesnt. This is a replacement for one that is lost
-
Is there a way to ADD photos to my iPad without replacing the ones already there? I am trying to add photos from a computer that does not contain photos already synced to the device.
You can use a USB flash drive & the camera connection kit.
Plug the USB flash drive into your computer & create a new folder titled DCIM. Then put your movie/photo files into the folder. The files must have a filename with exactly 8 characters long (no spaces) plus the file extension (i.e., my-movie.mov; DSCN0164.jpg).
Now plug the flash drive into the iPad using the camera connection kit. Open the Photos app, the movie/photo files should appear & you can import. (You can not export using the camera connection kit.)
Secrets of the iPad Camera Connection Kit
http://howto.cnet.com/8301-11310_39-57401068-285/secrets-of-the-ipad-camera-conn ection-kit/
Cheers, Tom -
500GB TC Hard Drive Failed: What Model Drive Do I Use To Replace Old One?
Dear Fellow Mac'ers:
Hopefully my title is pretty straightforward. My TC HD died. The router is fine.
1. What drive do I get to replace old one - Seagate Baracada ES? If so, what model?
2. How to info would be great - I'm hoping it will be easy.
3. What kind of installation do I need to do software-wise before operating again
Thanks!!!!
erniesfoSorry, it's been well over a year since I swapped out my drive. I believe there was an Hitachi drive in the device when I pulled it and I took it to an electronics / computer store to to get a drive that was physically the same size with more hard drive capacity. I used a Seagate drive for the replacement.
The article implies that drives from other manufacturers will work and I think recent generation TC's use another drive manufacturer. I would first pull the drive and take some measurements of dimensions...height, width and length and get some specs on the drives you are considering to compare and make sure that the new drive will fit into the allocated space.
As with any new purchase, I would suggest that you get a clear understanding of the store's return policy, just in case things don't work out as planned.
There are lots of articles on swapping out drives on a Time Capsule on the internet. Google something "what drive is used in a Time Capsule" and you'll see lots of stuff. -
Revision: 20754
Revision: 20754
Author: [email protected]
Date: 2011-03-10 03:36:05 -0800 (Thu, 10 Mar 2011)
Log Message:
My latest EndpointPushNotifier change changed the style of the code quite a bit (sorry for that, it was my IDE settings getting in the loop here) I only changed one char line 389.
Modified Paths:
blazeds/trunk/modules/core/src/flex/messaging/client/EndpointPushNotifier.javaI seem to have fixed it by putting <div class="clearfloat"></div> after the navigation bar?
-
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() ... -
Is Business Objects Xcelsius one of the many business objects?
Hi! Good morning!
Sorry for this newbie question.
I wonder that Is Business Objects Xcelsius one of the many business objects?
If so, where to find the complete list of all SAP BOBJ?
Thanks!One place to see:
SAP Service Market Place
https://websmp102.sap-ag.de/~SAPIDP/002006825000000234912001E
Thank You!!
Edited by: BOCP-BOE on Sep 30, 2010 6:26 PM -
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 -
if my iphone 5 is not blacklisted and warranty left ..... apple store replace new one?
either my iphone 5 was icloud activation locked....No. apple will not facilitate your ability to use a stolen phone.
If it is locked with YOUR Apple ID and you can't remember the ID or password, start at https://iforgot.apple.com. If you can't reset it there, call AppleCare and speak to someone in Account Security. Be prepared to prove your identity.
If it's locked with someone else's ID, they must release the lock. -
How can I combine one font with many styles to show up as one font
How can I combine one font with many styles to show up as one font? I have quite a few fonts, that instead of showing up as a single font with different font styles (bold, bolditalic, semibold, light....) each style shows up in the fonts dropdown menu as a separate font. Any way I can fix this?
Another font question, is there any way to group my fonts in the dropdown menu according to different categories such as 'favorite san serif fonts', or 'script fonts'?So your saying if it wasn't set up that way be the font creator there is nothing I can do. That's a shame.
Most of the fonts that do this were free fonts, such as Walkway.
But I do have some fonts (hebrew fonts) that I purchased that do the same thing.
Maybe you are looking for
-
Weird Problem calling Stored Procedure using JDBC
Scenario is.. I have J2EE application and calling stored procedure using JDBC. My application connects to instance "A" of testDB. Schema "A" does NOT own any packages/procedure but granted execute on oracle packages/procedures that reside in schema "
-
FCP to PP questions: part 5
13) In FCP if you right click on a clip it shows you, amongst other info, the duration of the clip in the timeline. I can't seem to find that same information in PP. Does it exist in an easily accessible way and if so where? 14) In FCP when you have
-
Can anybody tell me the difference, and can I use SO01 if I dont have auths for SBWP?
-
E3000 and guest account problems
I will add ot the E3000 funkiness, I have reset my router 6 times now trying to get the right combination of settings. What I am attemtping to do is simply change my SSID to my personal one and still have the guest account work. I change my SSID and
-
This started a week ago. Itunes forgets the position all the time. I listen to a lot of long MP3s and pretty much every time I pause an MP3, when i unpause it, it is like 20 minutes earlier than it was when I paused it. I have installed the newest ve