Removing non-alphanumeric characters

Hello,
New to Oracle (not so new to SQL) and this is my first post ... please be kind :-)
Anyway, I have a variable length string that I would like to separate into separate rows/columns. the structure is as follows:
|G^7130^R|C^7130^R|G^7131^R|C^7131^R|G^9900^R|C^9950^R|C^9951^R
... the leading alpha following the pipe is required in a column as is the numeric that follow. I have tried ...
REGEXP_REPLACE(string, '[^[:digit:]]',',') which gave me ...
,,,7130,,,,,7130,,,,,7131,,,,,7131,,,,,9900,,,,,9950,,,,,9951,,
..wrong...
I am trying to produce ..
code value
G 7130
C 7130
etc
Anyway any help would be appreciated .... and yes I am going through the literature as fast as I can ... well at least as fast as I can comprehend.
Thanks.
A

I am seeking some assistance on the implemenation of the above solution. I have modified the query (below) and am unsure of why the performance is so poor (no crticism to the contributers). When I run the Explain Plan against the SQL the total cost is very low (<50) ... yet when I run the query it does not return within hours (I cancel the process). Does anyone have any advice on this one? I have to be missing something here. Any help would be appreciated. Thanks.
Regards,
Al
Additional Info
-the largest table (request) has ~2.6 million rows the others <5000
-request index is:
ALL_DONE
REQNO
LABNO
-for the query below the set to be considered (pre-parsing) is only 171 rows. The first 50 come back in seconds but when I fetch the rest it does not return
select
distinct
rsl.ReqNo,
rsl.LabNo as RSL_Labno,
td.labno as DeptLabno,
td.dept,
case
when td.dept=1 then 'C'
when td.dept=2 then 'H'
when td.dept=3 then 'M'
when td.dept=4 then 'I'
when td.dept=5 then 'P'
when td.dept=6 then 'BB'
when td.dept=7 then 'R'
when td.dept=7 then 'MD'
end as Dept2,
ld.ldptname,
rsl.code,
rsl.test_code,
tm.alf_key,
tm.short_desc,
tm.text,
tm.end_date,
tm.orderable
from
with t1 as
(select
r.reqno as ReqNo,
r.labno as LabNo,
ti.tests as str
from
request r,
testinfo ti
where 1=1
and r.labno=11
and r.all_done = 0
and r.sp_dt>'01-JUN-08'
and r.reqno is not null
and r.reqno= ti.reqno
and r.labno= ti.labno),
t2 as
(select
regexp_substr(str,'[^|]+',1,level) sub_str,
ReqNo,
LabNo
from t1
connect by level<=nvl(length(regexp_replace(str,'[^|]')),1))
select
ReqNo,
LabNo,
substr(sub_str,1,1) code,
regexp_substr(sub_str,'[[:digit:]]+') test_code
from t2
rsl,
testmaster tm,
testdept td,
ldpt ld
where
1=1
and tm.test=rsl.test_code
and tm.test=td.test
and rsl.Labno=td.labno
and ld.labno=td.labno
and ld.dept=td.dept
and tm.end_date='31-DEC-49'
and td.end_date='31-DEC-49'
order by ReqNo, test_code asc;

Similar Messages

  • Removing Non-numeric characters from Alpha-numeric string

    Hi,
    I have one column in which i have Alpha-numeric data like
    COLUMN X
    +91 (876) 098 6789
    1-567-987-7655
    so on.
    I want to remove Non-numeric characters from above (space,'(',')',+,........)
    i want to write something generic (suppose some function to which i pass the column)
    thanks in advance,
    Mandip

    This variation uses the like operators pattern recognition to remove non alphanumeric characters. It also
    keeps decimals.
    Code Snippet
    CREATE FUNCTION dbo.RemoveChars(@Str varchar(1000))
    RETURNS VARCHAR(1000)
    BEGIN
    declare @NewStr varchar(1000),
    @i int
    set @i = 1
    set @NewStr = ''
    while @i <= len(@str)
    begin
    --grab digits or (| in regex) decimal
    if substring(@str,@i,1) like '%[0-9|.]%'
    begin
    set @NewStr = @NewStr + substring(@str,@i,1)
    end
    else
    begin
    set @NewStr = @NewStr
    end
    set @i = @i + 1
    end
    RETURN Rtrim(Ltrim(@NewStr))
    END
    GO
    Code to validate:
    Code Snippet
    declare @t table(
    TestStr varchar(100)
    insert into @t values ('+91 (8.76) \098 6789');
    insert into @t values ('1-567-987-7655');
    select dbo.RemoveChars(TestStr)
    from @t

  • Remove non-alphanumeric

    We are using Oracle 9i.
    How can i remove non-alphanumeric characters [ie , . ; : ( ) / \ etc] from a varchar2 field
    James

    Or
    michaels>  with t as
         (select     dbms_random.string ('p', 10) str
                from dual
          connect by level <= 10)
    select str,
           translate
              (str,
               'X'
               || translate
                    (str,
                     'X0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
                     'X'
               'X'
              ) without_special_characters
      from t
    STR                            WITHOUT_SPECIAL_CHARACTERS   
    CJy0*E[+}+                     CJy0E                        
    ."$2R="I`.                     2RI                          
    WiMK%ALkNT                     WiMKALkNT                    
    YDmz9\9`Z"                     YDmz99Z                      
    (*n?Zvs{xy                     nZvsxy                       
    1?Ci8HlG|Y                     1Ci8HlGY                     
    z6Ol&H_>r.                     z6OlHr                       
    @*TPM3`BH~                     TPM3BH                       
    <^+r>rmZB6                     rrmZB6                       
    75w+o.SO]N                     75woSON                      

  • Non-alphanumeric characters in textarea causing 404 errors

    I'm only just becoming acquainted with Coldfusion, as I've been asked to fix a problem in an existing system. The system consists of a simple html form containing a text area, among other input fields. The form is submitted to a cfm script, which displays a confirmation page and sends a couple of emails. The problem is that whenever the user enters any (as far as I can tell) non-alphanumeric characters, e.g. quotes, commas or brackets, in the textarea field, they get a 404 response from the server.
    I tried a number of things to identify the problem, including escaping the text in javascript before submission, but didn't get anywhere. The last thing I tried was installing a local version of the CF on my workstation, hoping to reproduce the problem and thus debug it more easily. However, on my local CF setup the problem does not occur.
    Can anyone help me debug this please? Thanks,
    Marcin

    Thanks for your response. The form method is "post". The only thing that the CFM handler does with this field (gametestexperience) is include it at the bottom of an email message:
    <CFMAIL TO="[email protected]"
    FROM="#email#"
    SUBJECT="Tester Application"
    type="html"
    server = "Cluster9.us.messagelabs.com">
      Automatically logged from the internet form:<p><p>
    <table>
    <tr><td>EmailFrom</td><td>#email#</td>
    <tr><td>From</td><td>#firstName# #lastName#</td></tr>
    <tr><td>Sent</td><td>#DateFormat(Now())#</td></tr>
    <tr><td>Referrer</td><td>#referer#</td></tr>
    <tr><td>Confirmation</td><td>#agree1#, #agree2#, #agree3#, #agree4#, #agree5#</td></tr>
    <tr><td>FamilyCompetitor</td><td>#familycompetitor#</td></tr>
    <tr><td>FamilyWork</td><td>#familywork#</td></tr>
    <tr><td>ReferredBy</td><td>#referredBy#</td></tr>
    <tr><td>RefererDetails</td><td>#refererdetails#</td></tr>
    <tr><td>FirstName</td><td>#firstName#</td></tr>
    <tr><td>LastName</td><td>#lastName#</td></tr>
    <tr><td>Email</td><td>#email#</td></tr>
    <tr><td>TelephoneHome</td><td>#telephoneHome#</td></tr>
    <tr><td>TelephoneCell</td><td>#telephoneCell#</td></tr>
    <tr><td>TelephoneDay</td><td>#telephoneDay#</td></tr>
    <tr><td>City</td><td>#homeTown#</td></tr>
    <tr><td>Employment</td><td>#employment#</td></tr>
    <tr><td>GamerType</td><td>#gamerType#</td></tr>
    <tr><td>GamerStyle</td><td>#gamerStyle#</td></tr>
    <tr><td>HoursPerWeek</td><td>#hoursPerWeek#</td></tr>
    <tr><td>PreferredGenres</td><td>#preferredGenres#</td></tr>
    <tr><td>Consoles</td><td>#console#</td></tr>
    <tr><td>GamesPlayed</td><td>#gameplayed#</td></tr>
    <tr><td>Available</td><td>#available#</td></tr>
    <tr><td>TestedBefore</td><td>#testedBefore#</td></tr>
    <tr><td>TestingExperience</td><td>#gametestexperience#</td></tr>
    </table>
      Thanks,<P>
      Focus Test Team!<P>
    </CFMAIL>

  • [solved] Non-alphanumeric characters broken in TinyChat

    Hello, fellow archers.
    I've been having a bit of trouble with the TinyChat site. Most non-alphanumeric characters are being displayed as crossed-out boxes. This problem is exclusive to TinyChat and has not occured in any other Flash applications.
    An example of the broken characters:
    Note how the / and > characters are not broken.
    This is the second installation of ArchLinux on my computer, the problem occured on the current install only. I suspect the problem is caused by a missing package, though the only hint I was able to find was installing the ttf-ms-fonts package (https://wiki.archlinux.org/index.php/br … ash_Player). This did not resolve the issue.
    Package versions:
    firefox 34.0.5-1
    flashplugin 11.2.202.425-1
    I'll gladly provide any other information that could help resolve this issue.
    Last edited by skoftoby (2015-01-21 18:31:26)

    Head_on_a_Stick wrote:
    skoftoby wrote:I'd like to request this topic be marked as solved either way.
    As with most things Arch, you have to do this yourself -- edit the title of your first post & put "[SOLVED]" at the beginning.
    Whops. The subject length was exactly at the maximum length, and since I couldn't edit the title any further, I thought a moderator had to edit it. Apologies!

  • How to support non alphanumeric characters when using WORLD_LEXER?

    BASIC_LEXER has an attribute of printjoins which we can specify the non alphanumberic characters as normal alphanumberic in query and included with the token. However, WORLD_LEXER doesn't have this attribute. So in order to use some non alphanumberic characters and treat them as alphanumberic characters in Oracle Text Index, such as ><$, what should I can?
    Thanks in advance for any help.

    I use WORLD_LEXER to create Oracle Text Index to support UTF-8.
    Below is the script to create table and index:
    REM Create table
    CREATE TABLE my_test
    ( id VARCHAR2(32 BYTE) NOT NULL,
    code VARCHAR2(100 BYTE) NOT NULL,
         CONSTRAINT "my_test_pk" PRIMARY KEY ("id"));
    REM create index
    exec ctx_ddl.create_preference('stars_lexer','WORLD_LEXER');
    exec ctx_ddl.create_preference('stars_wordlist', 'BASIC_WORDLIST');
    exec ctx_ddl.set_attribute('stars_wordlist','substring_index','TRUE');
    exec ctx_ddl.set_attribute('stars_wordlist','PREFIX_INDEX','TRUE');
    -- create index for Table corrosion level
    CREATE INDEX my_test_index
    ON my_test(code)
    INDEXTYPE IS CTXSYS.CONTEXT
    PARAMETERS ('LEXER stars_lexer STOPLIST stars_stop WORDLIST stars_wordlist SYNC(EVERY "SYSDATE+5/1440") TRANSACTIONAL');
    INSERT INTO my_test('1', 'English word1');
    INSERT INTO my_test('2', '违违');
    INSERT INTO my_test('3', '违违&^|违违');
    When I query:
    select * from corrosion_levels r where contains(r.CORROSION_LEVEL, '{%违${|违%}') > 0
    ID CODE
    3 违违$(|违违
    2 违违
    Actually, the result what I want is: 3 违违$(|违违
    So the requirement is that all non-alphanumeric characters should be treated as normal alphanumeric charcters. Please tell me how to implement it.

  • SQL*Loader-350: Illegal combination of non-alphanumeric characters

    Hi all,
    how to skip a column in control file.
    i.e.
    I have a table with 10 columns and FAT file contains 11 columns.
    how to skip a last column ?
    and
    I added extra column to Table and I changed the control file too.
    but i am getting error.
    SQL*Loader-350: Syntax error at line 115.
    Illegal combination of non-alphanumeric characters
    thanks in Advance.

    Tom Kyte has an elaborate solution on his page:
    http://osi.oracle.com/~tkyte/SkipCols/index.html
    Or post the table description and the control file, so we can have a look at it.

  • Removing non-numeric characters from string

    Hi there,
    I need to have the ability to remove non-numeric characters from a string and I do not know how to do this.
    Does any one know a way?
    Example:
    Present String: (02)-2345-4607
    Required String: 0223454607
    Thanks in advance

    Dear NickM
    Try this this will work...........
    create or replace function char2num(mstring in varchar2) return integer
    is
    -- Function to remove Special characters and alphebets from phone no. string field
    -- Author - Valid Bharde.(India-Mumbai)
    -- Date :- 20 Sept 2006.
    -- This Function will return numeric representation.
    -- The Folowing program is gifted to NickM with respect to his post on oracle site regarding Removing non-numeric characters from string on the said date
    mstatus number :=0;
    mnum number:=0;
    mrefstring varchar2(50);
    begin
    mnum := length(mstring);
    for x in 1..mnum loop
    if (ASCII(substr(upper(mstring),x,1)) >= 48 and ASCII(substr(upper(mstring),x,1)) <= 57) then
    mrefstring := mrefstring || substr(mstring,x,1);
    end if;
    end loop;
    return mrefstring;
    end;
    copy the above program and use it at function for example
    SQL> select char2num('(022)-453452781') from dual;
    CHAR2NUM('(022)-453452781')
    22453452781
    Chao!!!

  • Removing non printable characters from an excel file using powershell

    Hello,
    anyone know how to remove non printable characters from an excel file using powershell?
    thanks,
    jose.

    To add - Excel is a binary file.  It cannot be managed via external methods easily.  You can write a macro that can do this.  Post in the Excel forum and explain what you are seeing and get the MVPs there to show you how to use the macro facility
    to edit cells.  Outside of cell text "unprintable" characters are a normal part of Excel.
    ¯\_(ツ)_/¯

  • Removing non-printable characters

    Hi All,
    I was suppose to remove all non-printable characters, hence created below function. But in trouble for some rows in table.
    function ar1(i_value in varchar2)
    return varchar2
    as
           pattern varchar2(1000) := '][';
           l_strVal varchar2(1000);
    begin
           for i in 32 .. 126 loop
              pattern := pattern || case when chr(i) = '''' then ''''''
                                         when chr(i) in ('[', ']') then null
                                         else chr(i)
                                    end;
           end loop;
              l_strVal := regexp_replace(i_value, '([' || pattern || '])|.', '\1', 1, 0, 'n');
    return l_strVal;
    end;
    /Could anyone please help me, is this right way to do it.
    Problem is occurring for one row as shown below.
    SQL> select num, ar1(author) author1, author from doc where doc_num =37;
       NUM
    AUTHOR1
    AUTHOR
      15098137
    OM LESRAVI{|~
    OM LES
    RAVIIts removing non-printable characters but not sure how these {|~ are included in the resultant.
    Would be great if anyone can help me.
    Edited by: YasserRACDBA on Nov 9, 2010 3:53 PM

    Thanks....but even your method is giving worng result as shown below.
    SQL> select regexp_replace(author,'[[:cntrl:]]')
      2  from doc where doc_num =15098137;
    REGEXP_REPLACE(AUTHOR,'[[:CNTRL:]]')
    OM LESRAVI{|~Is there any clue please...how come those {|~ are there??                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Hot to set the Non-alphanumeric characters attribute?

    Hello,
    I'm developing an asp.net application using the oracle membership provider. I have installed the databse objects in an Oracle 9i and when I try to create a new user, It always asks me to consider at least 1 Non-alphanumeric character in the password, even if I put in the web.config file the minRequiredNonalphanumericCharacters="0" attribute. Is there another way to set the Non-alphanumeric characters to "0".
    Thanks.

    Workaround: set 0 for minRequiredNonalphanumericCharacters attribute in your machine.config for OracleMembershipProvider. The defalt value is 1. The typical location of machine.config is in %windir%\Microsoft.NET\Framework\v2.0.50727\CONFIG.

  • RegEx in TSQL - replace non-alphanumeric characters etc

    Hi guys, I have this function in VB that I used in Access to replace all non-alphanumeric characters, including spaces and anything in brackets.
    Public Function charactersonly(inputString As String) As String
    Dim RE As Object
    Set RE = CreateObject("vbscript.regexp")
    RE.Pattern = "\([^)]+\)|[^\w]|_"
    RE.Global = True
    charactersonly = RE.Replace(inputString, "")
    Set RE = Nothing
    End Function
    Now, I moved to SQL server and I'm writing scripts to do same thing.
    How can I use RegEx in TSQL?
    Only thing I will do is that function.

    As alternative
    declare @string varchar(200)
    set @string = 'gg$%^^&is%^& s2342jjk23&&({}e c76l232e+_+a#n/ c][#o''y#e'
    select cast(cast((select substring(@string,n,1)
    from numbers
    where n <= len(@string)
    and substring(@string,n,1) like '[0-9 ]' for xml path('')) as xml)as varchar(max))
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Non-alphanumeric characters part of a word?

    Hi,
    When searching using "23" the users have complained that it brings back terms like 23:00 and www.bob.....html?q=23. It's a bit of a long stretch but is there anyway to disregards those item.
    I expect I'll probably end up explaining to the users that non-alphanumeric characters are regarded in the same was as white spaces, but is this a general standard, and is there a link to more information anywhere?
    Cheers

    You could make your colon and equal sign printjoins or skipjoins.

  • Account Codes with non Alphanumeric characters

    I have a customer who has Business Partner Codes which contain non Alphanumeric characters :
    space
    full stop
    apostrophe
    forward slash
    hyphen
    Will this cause issues with the operation of any aspect of Webtools - what if anything should I watch out for since these cannot be changed?

    Thanks for your response. The form method is "post". The only thing that the CFM handler does with this field (gametestexperience) is include it at the bottom of an email message:
    <CFMAIL TO="[email protected]"
    FROM="#email#"
    SUBJECT="Tester Application"
    type="html"
    server = "Cluster9.us.messagelabs.com">
      Automatically logged from the internet form:<p><p>
    <table>
    <tr><td>EmailFrom</td><td>#email#</td>
    <tr><td>From</td><td>#firstName# #lastName#</td></tr>
    <tr><td>Sent</td><td>#DateFormat(Now())#</td></tr>
    <tr><td>Referrer</td><td>#referer#</td></tr>
    <tr><td>Confirmation</td><td>#agree1#, #agree2#, #agree3#, #agree4#, #agree5#</td></tr>
    <tr><td>FamilyCompetitor</td><td>#familycompetitor#</td></tr>
    <tr><td>FamilyWork</td><td>#familywork#</td></tr>
    <tr><td>ReferredBy</td><td>#referredBy#</td></tr>
    <tr><td>RefererDetails</td><td>#refererdetails#</td></tr>
    <tr><td>FirstName</td><td>#firstName#</td></tr>
    <tr><td>LastName</td><td>#lastName#</td></tr>
    <tr><td>Email</td><td>#email#</td></tr>
    <tr><td>TelephoneHome</td><td>#telephoneHome#</td></tr>
    <tr><td>TelephoneCell</td><td>#telephoneCell#</td></tr>
    <tr><td>TelephoneDay</td><td>#telephoneDay#</td></tr>
    <tr><td>City</td><td>#homeTown#</td></tr>
    <tr><td>Employment</td><td>#employment#</td></tr>
    <tr><td>GamerType</td><td>#gamerType#</td></tr>
    <tr><td>GamerStyle</td><td>#gamerStyle#</td></tr>
    <tr><td>HoursPerWeek</td><td>#hoursPerWeek#</td></tr>
    <tr><td>PreferredGenres</td><td>#preferredGenres#</td></tr>
    <tr><td>Consoles</td><td>#console#</td></tr>
    <tr><td>GamesPlayed</td><td>#gameplayed#</td></tr>
    <tr><td>Available</td><td>#available#</td></tr>
    <tr><td>TestedBefore</td><td>#testedBefore#</td></tr>
    <tr><td>TestingExperience</td><td>#gametestexperience#</td></tr>
    </table>
      Thanks,<P>
      Focus Test Team!<P>
    </CFMAIL>

  • Removing all non-alphanumeric characters

    Can anyone tell me where I can find a list of all "illegal" non-alphanumerci characters that I am not to use in any of file names. It was brought to my attention that bullets can really mess my system up.
    Some of my font folders have TM's (trademark) and some have "_" (underscores). What's the deal with those? Are they allowed? What about asteriks?
    I've got lots of questions about this so if anyone can shed some light, I'd appreciate it! Thanks

    OS X proscribed chars (from Help)
    "You cannot include a colon (:) in a filename or start a filename with a period (.). Some applications may not allow you to use a slash (/) in a filename."
    .Mac is more restrictive, as are some other operating systems.

Maybe you are looking for