REGEXP_REPLACE - case based replacement

Hi,
I'm not good with the usage of REGEXP_REPLACE. I need to replace following characters in a given string as below-
$ with USD
# with NO
= with EQ
% with PCT
given string example - '$100 5% DEBT = #5 DEBT'
desired output - 'USD100 5 PCT DEBT EQ NO 5 DEBT'
SELECT REGEXP_REPLACE('$100 5% DEBT = #5 DEBT',?,?)
FROM DUAL;I'm using 11g R2.
Thanks

Hi,
Regular expressions can do some amazing things, but they can't do everything. I don't think regular expressions will help in this problem.
If you only have 4 things to replace, then nested REPLACE functions, like the others suggested, are practical.
If you have many things to replace, MODEL can help you. See this thread:
SQL Query
Too bad you're not replacing single characters with other single characters; TRANSLATE can easily do that.

Similar Messages

  • ISH-CO Integration (Case based order could not be created)

    HI,
    My name is Yael Jacobi; I am a CO implementer in SAP Project in Israel.
    The project is for a hospital in Israel.
    We are trying to implement the integration between the CO (Controlling) and the ISH module.
    I haven't found any valuable information in the internet until now.
    I will be grateful if you could send me any documentation regarding the ISH-CO integration
    I am trying to create a case based order (internal order that should be created for a case in the ISH) but with no success.
    I created an internal order type in CO and customize the relevant data ,in the basic settings for "SAP Healthcare-integration with controlling" ,but no case based order had been created .
    The revenue posted to the profitability analysis segment instead of the case order.
    Maybe do you have any idea why is that and what is missing?
    I would really appreciate it if you could help,
    Thanks in advance;
    Best Regards,
    Yael

    Hi Yael,
    first of all good to hear that you solved the problem. Actually we have a couple of similiar processes where SAP Patient Management uses "standard" ERP functionality in the background. Sometimes it is a good strategy to first check out whether the "standard" functionality works as expected by invoking the respective transactions in ERP manually (using the values which you lateron expect IS-H to use automatically). If they work according to your expectations you can then focus on the IS-H configuration.
    I'd like to come back to your point on the documentation. If you write that you think it was not good enough, I am sure you have some ideas how to improve it? As you may know we are moving more and more into collaborative documentation technology like Wikis. Would you be willing to maybe actively help improving parts of the documentation by sharing some of your experiences and knowlegde?
    For example, we could jointly start a Wiki page on the topic of IS-H/CO integration.
    Please let me know your thoughts.
    Best regards
    Claudius

  • HT202450 Where do I get one of these  "bottom case foot replacement DIY kits"?

    Where do I get one of the "bottom case foot replacement DIY kits" as mentioned here: http://support.apple.com/kb/HT5236

         I have had the same situation ,3 of the 4 rubber foot felt down for some time and i manage to deal with this situation recentlly.I was thinking to change to whole back(have some scratches on the back cuz of the missing feet) but the Genius Bar representative told me is more then 100$ and gave up on the idea  .
        It cost me 30$(10$/foot...ridiculously expensive if you ask me because, i was out of apple care protection plan) and they mounted for me in about 20 minutes.
    If you are still under apple care,you'll likelly be covered for the cost.
    If you are not someone told me the feet can be purchased from Apple Care(2 feet per DIY kit,about 15$ per kit + S&H.The Apple Kit contains everything except the screwdriver (feet,alcoholl swabs,superglue).
    Try to contact Apple to ask or try a bit more research.
    Hope that helped.....Good Luck!!!

  • Would a Top Case keyboard replacement for Macbook Unibody A1342 (US version), be compatible w/my Macbook if originally it had a Japanese version?

    I bought a Macbook Unibody back in 2010, and until now the system is still working perfectly fine, probably because I keep on updating my software version, currently I am on Mac OS X 10.8.2 (Mountain Lion)...I don't have issues with it.
    I bought this Macbook in Japan, the keyboard version is on Japanese (with US alphabets) becaue I was studying Kanji back then, and apparently I am now living here in the Philippines and some of my keyboard keys are lost and they were taken off by my naughty niece (LOL, couldn't blame her though... she's just 2 years old)... now I am looking for a replacement. I couldn't find Japanese version of Top Case replacements here in Manila... now I kinda realized I might as well use a US version moving forward.
    Now my question is re: Top Case keyboard replacement for Macbook Unibody A1342 (US version), would it be compatible w/my Macbook if originally it had a Japanese version?
    Thanks in advance for all the help & informations. I would really appreciate it before I buy a replacement.
    Have a good one guys! ^_^)Y

    but it has been dropped a bit.
    Translation - It has been dropped multiple times.
    All the problems are likely related. Better get it to an Apple service rep and be aware that any warranty does not cover abuse of the product.

  • Top case got replaced; battery doesn't last as long as the old one

    My rMBP mid 2012 had a problem with the trackpad so I got the top case replaced, since the warraty was expired and I was stupid enoght not buy the apple care, It cost me around $650 USD, got it back last tuesday, everything seems to work fine except for the battery, it doesn't last as long as the old one, wich is kinda of wierd since the old one was around one and a half years old, should I consider taking it back to the Apple Premiun Reseller where I got it fixed? how common are these issues? Finally I read on reddit that I can ship my laptop to an official Apple store/service and got it diagnose or fixed? Is it worth it? I read that some folks got it exchange for a new one, the conditions of my laptop are pretty good, I have taken extreme good care of it, but some problems still arise, it has a couple of white stuck pixels in the display besides the problems that I already mentioned already.
    Cheers!

    AppleTechDenver wrote:
    I have the MacBook Air 11' and on http://apple.com it says the battery is supposed to last 9 hours.
    Did you read carefully?
    Note the words 'up to' not 'will' last 9 hours.  Apple makes these measurements based on very minimal resource intensive applications.  My experience that battery run time is much less than these unrealistic advertising claims.  Battery run time will be a function of the number and types of applications that are in use.
    Try a SMC reset:
    http://support.apple.com/en-us/HT201295
    That may improve things somewhat.
    Ciao.

  • Why do we have to replace the top case to replace a keyboard?

    I see replacement keyboards sold all over the place online which means they must be able to com apart from the case. If this wasn't possible then why are these parts for sale and who are they intended for? People keep saying that you must replace the top case but you can buy just the keyboard from many sources. Can someone clear this up please? There wouldn't be a market for just the keyboad if you couldn't do it, so it's hard to believe it can't be done.....

    Found two places on ifixit that explain how to do this... for anyone that may be looking for the same answer. You do NOT have to replace the entire upper case

  • How to use case to replace the & in select statement

    Oracle version : 11.1.0.6.0
    RHEL
    Hi,
    I want to get a list of all expired and locked users but want to replace the "&" with and here is my code but it isn't working.
    Please some guidance, thanks.
    SQL> select username,
    2 case (account_status like 'EXP%' then 'EXPIRED AND LOCKED'
    3 ELS 'no locked users'
    4 end) account_status
    5 from dba_users
    6 where account_status like 'EXPI%';
    case (account_status like 'EXP%' then 'EXPIRED AND LOCKED'
    ERROR at line 2:
    ORA-00907: missing right parenthesis

    798188 wrote:
    thanks for the comments I corrected the ELSE and 'EPX%' but still same error :
    EOH> select username,
    2 case (account_status like 'EXP%' then 'EXPIRED AND LOCKED'
    3 ELSE 'no locked users'
    4 end) account_status
    5 from dba_users
    6 where account_status like 'EXP%';
    case (account_status like 'EXP%' then 'EXPIRED AND LOCKED'
    ERROR at line 2:
    ORA-00907: missing right parenthesisFirst of all, you do not need a CASE statement.
    Did you see the where clause of your query??
    6 where account_status like 'EXP%';do you realise that your query will always return those records for which value of account_status column starts with 'EXP'?
    Why use CASE when it could be simply written like this :
    SELECT username,
           'EXPIRED AND LOCKED'
    FROM   dba_users
    WHERE  account_status LIKE 'EXP%'

  • Is the iPhone 5's case can replace ? and how much ?

    is iPhone 5's case can repalce ?

    An out of warranty replacement for an iPhone 5 is US$229 if you didn't purchase AppleCare+ with the phone.

  • Multiple cases based on Columns In SQL Query

    There is a SQL query given below, that query performs DateDIff operation by selecting max and min date according to
    TCard OR you can say id,
    here' the query
    SELECT
    --COUNT(DIFF)
    Count(DATEDIFF(D, MinDate, MaxDate)/30) AS DIFF
    FROM (
    SELECT
       MAX(TDate) AS MaxDate,
       MIN(TDate) AS MinDate
       FROM EDATA
       GROUP BY TCard
    )a
    Group by DATEDIFF(D, MinDate, MaxDate)/30
    Now i want to apply some kind of sorting in this query before performing DateDiff operation (sorting can be based on several parameters
    like age, name etc. but 1 at a time according to the cases) 
    Now I want to know How to apply cases over this query and where?

    You can apply sorting based on certain condition however you need to include those columns in your subquery. On custom sorting check out this article
    here:
    e.g.
    SELECT CountryName
    FROM   dbo.Country
    ORDER BY CASE WHEN
    CountryName = 'INDIA' THEN '1'
    WHEN CountryName = 'CHINA' THEN
    '2'
    ELSE CountryName END ASC
    If this post answers your query, please click "Mark As Answer" or "Vote as Helpful".

  • REGEXP_REPLACE issue/bug - replaces only every second occurence

    Hi All
    I am using
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE     10.2.0.1.0     Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    I need a regular expression to rename a variable in a mathematical formula, when testing my code I discovered that if the variable was repeated right after itself only one occurence was replaced. I need to only replace whole words as some variables can be a subset of a longer variable name, and variable names can have underscores in them.
    Below is an example of what happens.
    Can someone please tell me why this happens? Example code is:
    SELECT REGEXP_REPLACE('ab+ab+ab+ab+ab+ab+ab+abc+abc+ab', '(\W|^)ab(\W|$)' , '\1xy\2',1,0,'i') from DUAL;
    The regular expression matches all 'ab' with a non alpha character or beginning line before and a non alpha or end of line at the end.
    I then replace the 'ab' with 'xy' and keep the original non alpha on either side. What happens is that only every second occurence is replaced.
    If I place a space after every '+' then it replaces all occurences. (Obviously this is a user field in a table of mathematical formulas so I cannot expect the user to worry about this problem.)
    I believe it may be due to the fact the pointer in finding all occurence is moved incorrectly and it does not find the match immediately after.
    Can someone please explain this? Or am I missing something in my example.
    Thanks
    Dudley

    Is this what you require? I changed your query a bit.
    SQL> SELECT REGEXP_REPLACE ('ab+ab+ab+ab+ab+ab+ab+abc+abc+ab',
      2                         '(\W|^)ab(\W|$)',
      3                         '\1xy\2',
      4                         1,
      5                         0,
      6                         'i'
      7                        )
      8    FROM DUAL;
    REGEXP_REPLACE('AB+AB+AB+AB+AB+
    xy+ab+xy+ab+xy+ab+xy+abc+abc+xy
    1 row selected.
    SQL>
    SQL> SELECT REGEXP_REPLACE ('ab+ab+ab+ab+ab+ab+ab+abc+abc+ab',
      2                         '(ab)(\W|$)',
      3                         'xy\2',
      4                         1,
      5                         0,
      6                         'i'
      7                        )
      8    FROM DUAL;
    REGEXP_REPLACE('AB+AB+AB+AB+AB+
    xy+xy+xy+xy+xy+xy+xy+abc+abc+xy
    1 row selected.
    SQL> -- checking data with white spaces
    SQL> SELECT REGEXP_REPLACE ('ab + ab + ab + ab + ab + ab + ab + abc + abc + ab',
      2                         '(ab)(\W|$)',
      3                         'xy\2',
      4                         1,
      5                         0,
      6                         'i'
      7                        )
      8    FROM DUAL;
    REGEXP_REPLACE('AB+AB+AB+AB+AB+AB+AB+ABC+ABC+AB',
    xy + xy + xy + xy + xy + xy + xy + abc + abc + xy
    1 row selected.
    SQL> Regards,
    Jo

  • Can aluminum outer case be replaced?

    I have a 2008-09 version 15 inch MacBook Pro laptop.  I dropped my briefcase from about 2 feet.  The corner the laptop was damaged, still works fine, but ports don't line up with port hardware inside the outer case. 
    Can case be repaired/replaced and what would average cost be? 
    Thanks,  JRehling11

    HI!
    There is a slight chance that you will be able to simply take apart and put back together the housing of your computer and everything be fine. However, more than likely you will have to buy a completely new case for your computer which will cost you a pretty penny.

  • I DROPPED MY I-POD TOUCH AND BROKE THE FRONT OF IT BUT IT STILL WORKS. CAN THE CASE BE REPLACED SINCE THE INSIDE WORKINGS STILL WORK? IF SO WHERE CAN I GET IT FIXED AND HOW MUCH WOULD IT BE?

    I DROPPED MY I-POD TOUCH AND BROKE THE FRONT OF IT. I WANTED TO KNOW IF THE CASE COULD BE REPLACED AND IF SO WHERE CAN I GET IT REPLACED AND HOW MUCH?

    Out-of-Warranty Service: If your iPod requires service for any other hardware failure that is determined by Apple to be repairable, Apple will service your iPod for the Out-of-Warranty Repair Service fee.
    If you want to set up your iPod for the Out-of-warranty service, we recommend that you take your iPod to a local Apple Retail Store. Alternatively, you can contact Apple Technical Support.
    Click here for pricing.
    If Apple determines that an iPod is not repairable, for example, if it has failed due catastrophic damage or the iPod has been disassembled into multiple pieces, then Out-of-Warranty Service is not available and the iPod will be returned. Please see Apple's Repair Terms And Conditions for further details.
    copied from http://www.apple.com/support/ipod/service/faq

  • REGEXP_REPLACE: How to replace a list of words to null

    Hi,
    I need to replace if any word (from the list of words) is occoured in the given string, to null.
    I have tried the following:
    SELECT REGEXP_REPLACE(FIELD_NAME, 'and', '') AS RX_REPLACE FROM SAMPLE_TABLE;
    But it not working as expected.
    Your help is really appreciated on this.

    Here's a version that doesn't
    change the original string in any way:model is passing the whole string as many times as many iterations occur, here is one string access, without any original string transformations as well:
    SQL> WITH x AS(SELECT 'air the quick brown fox jumps command of and king to if all'  AS str
      2              FROM DUAL
      3             UNION ALL
      4            SELECT 'it it'
      5              FROM DUAL
      6             UNION ALL
      7            SELECT 'and xyz the if but for to is how or i a it of'
      8              FROM DUAL
      9             UNION ALL
    10            SELECT 'and the if but for to is how or i a it of'
    11              FROM DUAL
    12             UNION ALL
    13            SELECT 'xyz and the if but for to is how or i a it of'
    14              FROM DUAL
    15             UNION ALL
    16            SELECT 'and the if but for to is how or i a it of xyz'          
    17              FROM DUAL
    18             UNION ALL
    19            SELECT 'yet the if but for another to is how or i a it of test'
    20              FROM DUAL),
    21   m as (select '(and|the|of|if|but|for|to|is|how|it)' mask from dual)
    22  SELECT str,
    23         REGEXP_REPLACE(str,
    24                        '([^ ]' || mask || ')|(' || mask || '[^ ]+)|' || mask ||'|([^ ](i|a|or))|((i|a|or)[^ ]+)|i|a|or',
    25                        '\1\3\6\8')
    26    from x, m;
    STR                                                         REGEXP_REPLACE(STR,'([^]'||MAS
    air the quick brown fox jumps command of and king to if all air  quick brown fox jumps command   king   all
    it it                                                      
    and xyz the if but for to is how or i a it of                xyz
    and the if but for to is how or i a it of                  
    xyz and the if but for to is how or i a it of               xyz
    and the if but for to is how or i a it of xyz                            xyz
    yet the if but for another to is how or i a it of test      yet     another         test
    7 rows selected
    SQL> kind of same technique is described here:
    http://volder-notes.blogspot.com/2007/12/regexp-4-number-of-occurence-advanced.html

  • Auto Creation of Dispute Case based on dunning level

    Dear All
    We want to create the dispute case automatically using T.Code FDM_Auto_Create. We want to default the title as dunning level + External reference. We know the BADI for this but how to check which dispute cases are created automatically due to dunning level.
    Thanks and Best Regards
    Farhan Qaiser

    Hi Farhan,
    I presume you are creating your disputes against open items, and not incoming payments.
    If this is correct, the dunning level field is part of the selection parameter.
    Are you planning on disputing all open items, that have a specific Dunning level, if that is the case you can include this in your selection parameter.

  • Regexp_replace doesn't replace anymore

    HI all,
    I recently had to downgrade my database version from 10.2.0.3 TO 10.2.0.1 (see below for details).
    Since this changement, a call to regexp_replace doesn't work anymore.
    Here is a sample code :
    DECLARE
    ctx dbms_xmlgen.ctxHandle;
    xml CLOB;
    req varchar2(4000);
    BEGIN
    req := 'SELECT table_name FROM user_tables';
    ctx:=dbms_xmlgen.newcontext(req);
    dbms_xmlgen.setnullhandling(ctx, dbms_xmlgen.EMPTY_TAG);
    xml := dbms_xmlgen.getxml(ctx);
    IF dbms_xmlgen.GETNUMROWSPROCESSED (ctx) = 0 THEN
    xml := '<?xml version="1.0" encoding="ISO-8859-1"?>';
    xml := xml || '<ROWSET/>';
    ELSE
    xml := regexp_replace( xml, '^<\?xml(.+?)\?>', '<?xml\1 encoding="ISO-8859-1"?>');-- Call that does'nt work
    END IF;
    dbms_xmlgen.closeContext(ctx);
    dbms_output.put_line('* AFTER *' || xml);
    dbms_xmlgen.closeContext(ctx);
    END;
    /The output xml is blank ('* AFTER *' || xml) whereas in last version it was not.
    I can't find any relation between regexp_replace and Oracle 10.2.0.3.
    TIA
    Stephan
    LAST version
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
    PL/SQL Release 10.2.0.3.0 - Production
    "CORE     10.2.0.3.0     Production"
    TNS for Linux: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - ProductionNEW version
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    "CORE     10.2.0.1.0     Production"
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production

    Test 1
    select regexp_replace( '<?xml version="1.0"?>' , '^<\?xml(.+?)\?>', '<?xml\1 encoding="ISO-8859-1"?>') from dual;OUTPUT
    REGEXP_REPLACE('<?XMLVERSION="1.0"?>','^<\?XML(.+?)\?>','<?XML\1ENCODING="ISO-8859-1"?>')
    <?xml version="1.0" encoding="ISO-8859-1"?>
    1 rows selected-------------------------------------------------
    Test 2
    /* and do the same with the previous :xml variable */
    var x clob;
    exec :xml := '<?xml version="1.0"?>';
    select regexp_replace( :xml , '^<\?xml(.+?)\?>', '<?xml\1 encoding="ISO-8859-1"?>') from dual;OUTPUT
    anonymous block completed
    REGEXP_REPLACE(:XML,'^<\?XML(.+?)\?>','<?XML\1ENCODING="ISO8859-1"?>')
    (CLOB) (CLOB) <?xml version="1.0"?>
    1 rows selectedStrange... isn't it ?
    Test 3
    set role NONE
    (...) OUTPUT
    set role réussi.
    anonymous block completed
    * in between *<?xml version="1.0"?>
    <ROWSET>
    <ROW>
    <TABLE_NAME>N43005</TABLE_NAME>
    </ROW>
    <ROW>
    <TABLE_NAME>N43010</TABLE_NAME>
    </ROW>
    <ROW>
    <TABLE_NAME>N43011</TABLE_NAME>
    </ROW>
    <ROW>
    <TABLE_NAME>N
    * AFTER *
    Nothing after "* AFTER *".

Maybe you are looking for

  • HT1918 How can I merge two Apple IDs?

    Had a previous account but then when I bought my first iPhone. (iPhone 5) I thought I had to set a new account. So now I want to be able to use one ID that has all.

  • 10.5.8 updated killed Write/Update permissions on my Boot camp partition.

    I can't figure this one out. I regularly "reach over" to my boot camp partition to move files from XP to my mac, and have automator scripts that also do that. Since the update, it no longer works either manually or via automator. I can read and copy

  • JTable and the ****** TableModel

    Ok, I know I'm messing with all of these threads about table and table model but there is no way for me to understand: I do MyTable table = new MyTable( rowData, column ); public class MyTable extends JTabel { MyTableModel myMod = null; public MyTabl

  • A Question reguarding burning a DVD

    I have made one dvd and am trying to make a second or third copy. I have put the 2nd disk in and it goes thru all the stages of burning; all the way to finish recording. It spits out the disk and hangs here. It never asks if I want another copy. Some

  • Iphone 3gs problem on ios 6.0

    I have an iphone 3gs updated to ios 6 and it suddenly says no service and keeps shuting off, and once it turns back on it says to connect to itunes but shuts off before i can do anything. please help!!!