Find special characters in a string
Hi all, I am using Oracle 10 g.I have a column name with special characters. How can I replace the special characters in the column with space and no space based on the special character. Please see the example below. can I use REGEXP_REPLACE?
create table
create table sample_test (
Name VARCHAR2(20 BYTE))
Insert a table insert into sample_test values ('O''NEIL')
insert into sample_test values ('B.E.VICTOR')
insert into sample_test values ('WILLIAM,L')
insert into sample_test values ('MARY-ANNE')
insert into sample_test values ('VON_ANCKEN')
insert into sample_test values ('BROWN;L')
I would like the following output
Special Character Name Expected Name Remarks
Single Quotes O'NEIL ONEIL Remove quotes and no space
Dot B.E.VICTOR B E VICTOR Replace with space
Comma WILLIAM,L WILLIAM L Replace with space
Hyphen MARY-ANNE MARY ANNE Replace with space
Underscore VON_ANCKEN VON ANCKEN Replace with space
Semi Colon BROWN;L BROWN L Replace with space
Please notify.Thank you
Bob
A simple solution without the use of regexp:
-- Test Data
with sample_test as
(
select 'O''NEIL' name from dual union all
select 'B.E.VICTOR' name from dual union all
select'WILLIAM,L' name from dual union all
select'MARY-ANNE' name from dual union all
select'VON_ANCKEN' name from dual union all
select'BROWN;L' name from dual
)
-- Query:
select name old_name,
translate(replace(name,'''',''),'.,-_;',' ') new_name
from sample_test;
Explanation:
REPLACE deletes the quote
TRANSLATE replaces point, comma, dash, semicolon and underscore
Tags: Database
Similar Questions
-
How to find special characters in a string of give/sentance
Hi all
I have a task to complete with the time to give. Because I'm not very good in PL/SQL, I need you're help.
Condition is:
I must come with the SQL or PL/SQL code which should return and find the hidden or special character in the name of the data files in a database. There are nearly 400 + database are present in almost any flavor of UNIX, and I need to check the database each.
As you know, the name of the data file will be like this:
So, it should avoid these things and only discover the special characters in the name of the data file./u02/instance_name\oradata\datafile_01.dbf
Please keep in mind that... I'll be pulled the script Oracle the Oracle 9i client that will access all the databases of Oracle 9i to 11g in a short and give me the result.a-z , A-Z , 0-9 and \
Please help me to solve this problem and let me know if you need more information.Hello
Mukesh says:
Hi Frank,.It is an excellent service. Thanks for you response.
I want to change the query that... I should get only the name of these data files that are special characters of detention. I don't know how to put it in that condition. :(Here's one way:
SELECT file_name , ... -- other expressions, if you want any FROM dba_data_files WHERE TRANSLATE ( file_name , '?0123456789.ABCDEFGHIJKLMNOPQRSTUVWXYZ\_/abcdefghijklmnopqrstuvwxyz' , '?' ) IS NOT NULL
Among other expressions, you can put in the SELECT clause (if you wish) is a copy of the TRANSLATE function, you had in your message. That would underline exactly what characters rendering invalid file name.
-
Find special characters in the name of the Image
Hi all
Request:
1. the need to find special characters or unwanted characters in the name of links (Figure$ .eps, abcd? cde.jpeg etc.)
2. the name links allows only [a - z] or [A - Z] or [0-9]
3. name links does not allow special characters such as (i.e.,?,!, @, $ etc...)
4. white space not allowed
Very urgent request...
Try the Code is:
var myLinks = app.documents[0].links.everyItem().getElements(); alert(myLinks.length) for(i=0; i<myLinks.length; i++) { var mySplit = myLinks[i].name.split("."); var myFinal = mySplit[0]; for(k=0; k<myFinal.length; k++) { if(String(myFinal[k]).match(/[a-z]/g) !=null || String(myFinal[k]).match(/[A-Z]/g) !=null || String(myFinal[k]).match(/[0-9]/) !=null ) { alert(myFinal); break; } } }
Thanks in advance
Siraj
Hi Siraj
Try this out
var myLinks = app.documents[0].links.everyItem().getElements(), badCharReg = /[^A-z0-9]/g, l = myLinks.length, badLinks = [], linkName = ""; while (l--) { linkName = myLinks[l].name.split(".")[0]; if (badCharReg.test(linkName)) badLinks.push(linkName); } if (badLinks.length) alert("Check out these\n"+badLinks.join("\n")); else alert("Have a nice day");
Trevor
-
Bunch of Oracle on the special characters in a string - translate?
How to remove special characters in a string, it can contain. , (space), etc.
SELECT TRANSLATE('123.456 (90-90)', '', '') FROM DUAL
Basically I want to undress and to compare with the db value.
WHERE TRANSLATE(TABLE.NUMCODE, '', '') = TRANSLATE('123.456 (90-90)', '', '')
Use TRANSLATE, since you're on 9i. For example:
TRANSLATE (your_string,'X,. #! % @$ ^ & * () _-+=', 'X')
Removes all the s characters in ', #! % @$ ^ & * () _-+=' of your_string.
SY.
-
Hi all
I am trying to remove special characters without the help of regular expressions.
translate (the column name or string,'!@#$ & * (* () _) * "" :} {?}) >? /, «, » ')
I want to eliminate this manual process to give all special characters using a chr() or ascii() function.
Please show me the way.
Thanks in advance
Similar to the solution of Michael...
SQL > ed
A written file afiedt.buf1 with t as (select "[it comes of the #] [more amazing!") Test @# "$* & $%) assuming chain cost $ 5 000' double Str)
2, i like (select level 1 c from dual connect by level<=>=>
3 less
4 Select + 32 (level-1) double connect by level<=>=>
5 less
6 select + 58 (level-1) double connect by level<=>=>
7 less
8 select + 91 (level-1) double connect by level<=>=>
9 less
10. Select 123 + (level-1) from dual connect by level<=>=>
11 less
12. Select 255 double
13 )
14, ts as (select level r, substr (str, level 1) c
15 t
16 connect by level<=>=>
17 )
18, tf as (select row_number() (order for r) r
19 ,ts.c
20 TS
21 I join on (i.c = ascii (ts.c))
22 )
23 select replace (sys_connect_by_path(c,'!'),'! ') Str
24 TF
25 where connect_by_isleaf = 1
26 connect r = prior r + 1
27 * start with r = 1
SQL > /.STR
-----------------------------------------------------------------------------------------------------------------------
Thisisthemostamazingtest¸astringcosting5000Or something as horrible as this...
SQL > ed
A written file afiedt.buf1 with t as (select "[it comes of the #] [more amazing!") Test @# "$* & $%) assuming chain cost $ 5 000' double Str)
2, I like (select replace (sys_connect_by_path (chr (c), 'A'), 'A') as tr)
3 of)
4 select c, rownum r
5 (select 32 + (level-1) as the double connection by level c<=>=>
6 union
7 select + 58 (level-1) double connect by level<=>=>
8 union
9 select + 91 (level-1) double connect by level<=>=>
10 the union
11. Select 123 + (level-1) from dual connect by level<=>=>
12 union
13. Select 255 double
14 tri 1
15 )
16 )
17 where connect_by_isleaf = 1
18 log r = prior r + 1
19 start with r = 1
20 )
21 select translate (str, 'A' |) TR, 'A') as str
22 * t, I
SQL > /.STR
--------------------------------------------------------------------
Thisisthemostamazingtest¸astringcosting5000 -
How to find special characters in a single query
Dear Experts,
Your usual help is needed to resolve the query. My query is ' how to find all special characters such as (% $* & @, ' / +-etc. in a single query?).
Thank you.
for example
A_MIR
A % SIM
A * SIM
SIM HAS)Hello
This can work:
select * from your_table where replace(translate(your_column,' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890','x'),'x','') is not null
Above code verifies an ascii and numbers. You can adjust the chain with other characters you want to see (exclude)
Herald tiomela
http://htendam.WordPress.com -
Hello
I have a table which has got a customer detail field have only numbers and the alpahbets is to say a to z, A to Z, 0 to 9. However, due to the fault of typing, there are some special characters entered in this field.
How can I find all the lines with special character in this area. y at - it a function or an easy way to do it. I use the version of oracle 10g.
Thanks for your help.
Rgds,
Sharan.user REGEXP_LIKE
select * from
where regexp_like( , '[^[[:alnum:]]]*') -
How to avoid special characters in a string
Hai.
I want only Alphabets & numbers to appear on my channel. No other special characters except spaces. How can I do this?
Hi Alice,.
See the attached example.
It will be useful.
Mike
-
How to avoid special characters in the string box
Hello
is it possible that a special character can be avoided in a box of the string, as authorizing only a - z and 0-9 to enter a box in the chain
Hi all
Darin Laurette method is simple.
AnkitG: You must change the code.
Good learning for me.
Kind regards
Leila
CLD
-
REGEXP_REPLACE problem with special characters in the string
Hi guys,.
I have had problems using the REGEXP_REPLACE function and I'm trying to find a solution.
The closest I can get is this thread:
and that's only because the solution, I'm trying to achieve is the one suggested. I did ppost my problem there, but because it is answered, I don't have an answer.
I'm doing the following:
Basically, replace it does not work, because the first part of the string contains an asterisk. If you delete the Asterix, then replace it won't work.select regexp_replace('A*|A*|C11|A1|A*||_|OR|H452|C40|A|A*||_|AA|1151|G31|A1|A||_|EX|8HI01|H11|A1|A||_|OCR|H421|B11|A|||_|OR|H434|C11|A|||_|AQA|9990|E10|EP|||_|AA|2151|G31|A|||_|', '^(\w|-)*\|{1}',null) from dual
How can I get around this? I can't use a regular REPLACEMENT as I want to remove the first instance of A * and not all instances of the A.
Help, please! I don't know what to do... probably, I mustn't start a loop through the string?
Thanks in advance guys!
RobinUser_resU wrote:
I want to remove the first instance of A * and not all instances of the A.To decode your regular expression, it seems that you want to remove A * | and not just A *.
SQL> select regexp_replace('A*|A*|C11|A1|A*||_|OR|H452|C40|A|A*||_|AA|1151|G31 |A1|A||_|EX|8HI01|H11|A1|A||_|OCR|H421|B11|A|||_|OR|H434|C11|A|||_|AQA|9990|E10| EP|||_|AA|2151|G31|A|||_|', 2 '^(\w|-)\*\|{1}',null) reg 3 from dual; REG -------------------------------------------------------------------------------- A*|C11|A1|A*||_|OR|H452|C40|A|A*||_|AA|1151|G31|A1|A||_|EX|8HI01|H11|A1|A||_|OCR |H421|B11|A|||_|OR|H434|C11|A|||_|AQA|9990|E10|EP|||_|AA|2151|G31|A|||_|
-
Replace special characters in a string
Let's say that someone copies the list as follows and the glue in a Javascript dialog box:
302304
305678
245675
How do I manipulate the string so that it reads:
302304 305678 245675
In other words, how to replace manual line breaks in a string with spaces?
Thank you!
It's the cleanest method that you are looking for:
/[\n\r]/
In this case, even a simple \s would work, but it's maybe not what the OP...
Substances
-
JSON format - Date and special characters
Hi all
I had a JSON server in which, I have a few text values and date.
- How can I convert special characters to normal String.e.g. Comma etc. ?
- How can I convert long date, a string in the format e.g. "1345670466960-0400"?
I really appreciate any help above.
Solved... Where the above closure. For others, I will post the solution.
Special characters-
QByteArray buffer(bufSize, 0); int read = reply->read(buffer.data(), available); //response = QString(buffer); -- Wrong way to convert the bytes. response = QString::fromUtf8(buffer); // right way, so special character handled itself.
Day fromatting - for example "/ Date (1345670466960-0400).
QString getStringDate(QString k){ QDateTime date = QDateTime::fromTime_t(getDate(k)); QString strDate = date.toString("MM/dd/yyyy HH:mm:ss"); return strDate; } long getDate(QString k) { long rc = 0; QString v = k; if (v.length() > 0 ) { int b = v.indexOf("/Date("); if (b >= 0) { b += 6; int e = v.indexOf(')', b); if (e > b) { QString s = v.mid(b, e); int sign = 1; if (s.indexOf('-') > 0 || s.indexOf('+') > 0) { sign = s.indexOf('-') > 0 ? -1 : 1; e = sign < 0 ? s.indexOf('-') : s.indexOf('+'); s = s.mid(0, e); } bool *ok = false; s = s.mid(0, s.length() - 3); //trimming it for seconds only.... rc = s.toLong(ok, 0); } } } return rc; }
-
Where to find and install special characters in Firefox?
Where to find and install special characters sets (French, German and Spanish) in my Firefox with Dutch language?
TIA
JoepTranslation:
TOOLS = > Options = > content = > languages = > click "Select" and then "select a language to add."
For the character encoding:
TOOLS = > Options = > content = > fonts and colors = > advanced (button) = > character encoding
-
I try to put a few Spanish words in a document and must be able to select vowels with accents or we the n with a tilde over it. Where can I find this window that lets me select these special characters?
You can use the glyphs Panel.
-
Special characters in the variable string sent from php.
Hello. Assuming that I have send a php string variable in flash:
AS3:
var MyImportedString:String;
var variables_page_text:URLVariables = new URLVariables();
var varSend_page_text:URLRequest = new URLRequest("MyPHP.php");
varSend_page_text method in the group URLRequestMethod.POST;
varSend_page_text data in the Group variables_page_text;
var varLoader_page_text:URLLoader = new URLLoader;
varLoader_page_text the dataFormat group pouvez;
varLoader_page_text. addEventListener (Event.COMPLETE, var_comp_page_text);
varLoader_page_text. load (varSend_page_text);
( function var_comp_page_text() event: Event(): void {}
MyImportedString = event.target.data. $myvariable;
}
PHP:
<? PHP
header (' Content-Type: text/html; charset = utf - 8');
$mystring1 = "some text &";
Print "$myvariable =" . $mystring1;
? >
I noticed that the special '&' residing inside the string character, throws an error: #2101: the string passed to URLVariables.Decode must be a query string URL-encoded containing name/value pairs.
My first thought was, it has something to do with the html entities, but other entities (such as <> or """) do not throw any error. In addition, the use of php functions like htmlentities(). or html_entity_decode(); makes no difference in this case:
Print "$myvariable =" . htmlentities ($mystring1);
or
Print "$myvariable =" . html_entity_decode ($mystring1);
I also noticed that the characters such as '%', ' ^', '+' appear at all;
What it means? Any ideas?
Reagards.
This function generally works pretty well:
function flash_encode($string)
{
$string = rawurlencode(utf8_encode($string));$string = str_replace("%C2%96", "-", $string);
$string = str_replace("%C2%91", "%27", $string);
$string = str_replace("%C2%92", "%27", $string);
$string = str_replace("%C2%82", "%27", $string);
$string = str_replace("%C2%93", "%22", $string);
$string = str_replace("%C2%94", "%22", $string);
$string = str_replace("%C2%84", "%22", $string);
$string = str_replace("%C2%8B", "%C2%AB", $string);
$string = str_replace("%C2%9B", "%C2%BB", $string);return $string;
}
?>
Maybe you are looking for
-
How can I change the download directory in Firefox Android?
Downloads on Android Firefox go to the directory/sdcard/Downloads. Is it possible to change this download location?
-
I downloaded and tried a few plug-ins from third parties who are drafted for Aperture (more Photoshop, etc.). They worked fine, but don't actually do anything, I am interested. So I removed the my iMac. Unfortunately they still appear in the opening
-
How to record various objects used by an external C function
I want to do my own LV component that calls a C function that uses an external API. For the first time, my function is called, it creates and defines variables and some API objects and store them. If the future my function calls do not need to define
-
Internet Windows CE 6.0 problems, I have a connection, but can not surf the net
I recently bought a netbook with Windows CE 6.0 and I get no internet to work to save my life. I am connected to my wifi but when I open IE it says cannot display the page. Help, please!
-
My T41p crashes after a few minutes. I decided to shut it down and when I run upward it lights but will not show all the lights and custom begin to run until I have power on/off or unplug and turn the computer back on. The weird part is that when I r