Regular Expressions like feature in 9i

Hi Friends,
The sample data stored in one of the columns in the database is as follows:
SELECT *
FROM
SELECT 'MTC-1039195130-Elcoteq' location FROM DUAL UNION ALL
SELECT 'MTC Foxconn India' FROM DUAL UNION ALL
SELECT 'MTC_Hosiden_1798467' FROM DUAL UNION ALL
SELECT 'EMS- MTC-QISDA CORPORATION' FROM DUAL UNION ALL
SELECT 'EMS MTC-BANSHING HKG' FROM DUAL
)In all these,i want to replace MTC with XXX.
Database Version:Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production

Hi,
Connected to Oracle9i Enterprise Edition Release 9.2.0.8.0
Connected as hr
SQL>
SQL> with data as
  2      (
  3      SELECT 'abcMTC MTC' location FROM DUAL UNION ALL
  4      SELECT 'abcmtc mtc' FROM DUAL UNION ALL
  5      SELECT 'abc-mtc-zzz' FROM DUAL UNION ALL
  6      SELECT 'EMS- MTC-QISDA CORPORATION' FROM DUAL UNION ALL
  7      SELECT 'EMS MTC-BANSHING HKG' FROM DUAL
  8      )
  9      select location, replace(replace(replace(location, ' MTC', ' XXX'), ' mtc', ' XXX'), '-MTC', '-XXX') FROM DATA;
LOCATION                   REPLACE(REPLACE(REPLACE(LOCATI
abcMTC MTC                 abcMTC XXX
abcmtc mtc                 abcmtc XXX
abc-mtc-zzz                abc-mtc-zzz
EMS- MTC-QISDA CORPORATION EMS- XXX-QISDA CORPORATION
EMS MTC-BANSHING HKG       EMS XXX-BANSHING HKG
SQL> Regards,

Similar Messages

  • Search with regular expression like this "[^\(]+mytype"

    I tried regular expression which find me line which has "mytype" but does not precede with "("
    I wrote it like this:    [^\(]+mytype
    It works perfectly with python reg exp. But it does not work in MSVC 2013 search(ctrl+shift+f). Do you know why? Is it bug?
    Is there a way to find variable definition with search function through whole project

    Hi Vit,
    According to your description, you mean that when you use the
    ctrl+shift+f shortcut key to search which line has "mytype" word in the whole project from VS2013 IDE like the following screen shot, but it does not work
    in VS2013 IDE, am I right?
    If yes, could you please provide me a screen shot about how you search the
    mytype?
    Generally, when we used the
    ctrl+shift+f shortcut key to search, it works fine in VS IDE. Therefore, to check if you install some third-party Add-ins impact your VS IDE, I suggest you can search
    the mytype in VS safe mode check if you get same issue.
    Reference:
    http://msdn.microsoft.com/en-us/library/ms241278.aspx
    (1)If you did not get same issue, I doubt that you may be install some Add-ins impact the VS IDE, so I suggest
    you can try to disable or un-install them and then check this issue again.
    (2)If you still get same issue, I suggest you can try to reset the VS setting file or you can try to repair your
    VS check this issue again.
    In addition, I suggest you can try to use Ctrl + F shortcut key to search the mytype word.
    If I misunderstand your issue, please provide me more detail message about your issue.
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How about the statement of regular expression like for this

    I what to get varians String array by one regular express for the statement like:
    ${user} like play ${game} in ${date}
    I want to get String[] as {"user","game","date"} by one regex, by str.split(regex). I tried many times but always fail to get the result I expected. May it be possible to meet the destination?
    thanks in advance
    Frederick

    why StringBuffer was using here?So one could split the pattern into multiple lines. But it just occurred to me that one could just use string concatenation, which would look better. I don't know why I bothered to use StringBuffefer.
    e.g.:
    String pattern =
        "^" +           // the start of a string
        "(dog)|(cat)" + // match either "dog" or "cat" at the start of the line
        "\\s*" +        // match an arbitrary amount of whitespace
        "$";            // but don't allow anything other than whitespace after dog or cat
    Pattern p = Pattern.compile(pattern);
    Pattern p = Pattern.compile("^(dog)|(cat)\\s*$");> isn't this look more simpler and better?
    In this case, yes. I was looking for a way to make regexps more explicit, with whitespace and comments, for more complicated cases.
    But those double quotes and plus signs add ugliness of their own, so a regexp would have to be pretty complex before it would be an improvement.

  • How to split a string with a delimiting regular expression like "\r"

    Hello!I am a fresh in java programming.Please don't deride my question.What I want to realize is to get the current caret lines and cols in a JTextPane. My question is :After I fetch the string content of the JTextPane and try to split it with the end-line token like "\r" or "\r\n",it always comes me an wrong position.
    here is my code:
    public void caretUpdate(CaretEvent e) {
    int ln,col;
    JTextPane textSource = (JTextPane)e.getSource();
    String sourceString = textSource.getText();
    String subString = sourceString.substring(0,
         (e.getDot() == 0) ? 0 : e.getDot()-1);
    String[] splitString = subString.split("\r",-1);
    ln = splitString.length;
    col = e.getDot() - subString.lastIndexOf("\r");
    setCaretPosition(ln,col); //display ln and col in a label
    I have got puzzled>_<.Please help me.Any help would be appreciated . (^-^)

    Swing text components always use "\n" to separate lines, not "\r" or "\r\n". When you read text in from a file or paste from the clipboard, the line separators are converted to "\n" if necessary. They save the info about what line separators were used in the source file, so if you write the text back to a file it converts them back.

  • How to use special characters in regular expression

    HI all, I am new to regular expression.
    Can any one please tell me the regular expression for characters which are used in regular expression like " [({. tetc.Is there any particular expression to prefix before using these characters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Expression:
    < td .*? bgcolor = \" ( [^ \" ] +) \" \\s* .*? > ( .+? ) </td>
    It will search for expression starting with <td ,
    .*? means any characters zero or more than one,
    then it will find bgcolor = , then literal \"... \(any char) is that specific char
    [ ^ \" ] any character but not literal \",this means there has to be something between ".... " if empty then wont match ,+ is 1 or more times
    Then again literal \ " , after that \\s* means zero or more num of spaces,
    then again , .*? means any characters zero or more than one,
    it will search for literal > , again any chars . * ?
    Finally </td> will be searched.....!!
    So all expressions having this particular structure will be
    matched.
    Output :
    <td align="left" valign="top" bgcolor="ffffff" width="177">bla bla bla</td>

  • Problem in creating a Regular Expression with gnu

    Hi All,
    iam trying to create a regular expression using gnu package api..
    gnu.regex.RE;
    i need to validate the browser's(MSIE) userAgent through my regular expression
    userAgent is like :First one ==> Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
    i wrote an regular expression like this:
    Mozilla.*(.*)\\s*(.*)compatible;\\s*MSIE(.*)\\s*(.*)([0-9]\\.[0-9])(.*);\\s*(.*)Windows(.*)\\s*NT(.*)\\s*5.0(.*)
    Actaully this is validating my userAgent and returns true, my problem is, it is returning true if userAgent is having more words at the end after Windows NT 5.0 like Second One ==> Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) Testing
    i want the regularExpression pattern to validate the First one and return true for it, and has to return false for the Second one..
    my code is:
    import gnu.regexp.*;
    import gnu.regexp.REException;
    public class TestRegexp
    public static boolean getUserAgentDetails(String userAgent)
         boolean isvalid = false;
         RE regexp = new RE("Mozilla.*(.*)\\s*(.*)compatible;\\s*MSIE(.*)\\s*(.*)([0-9]\\.[0-9])(.*);\\s*(.*)Windows(.*)\\s*NT(.*)\\s*5.0(.*)");
         isvalid = regexp.isMatch(userAgent);
         return isvalid;
    public static void main(String a[])
         String userAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)";
         boolean regoutput = getUserAgentDetails(userAgent);
         System.out.println("***** regoutput is ****** " + regoutput);
    }please help me in solving this..
    Thanks in Advance..
    thanx,
    krishna

    Ofcourse, i can do comparision with simple string matching..
    but problem is the userAgent that i want to support is for all the MSIE versions ranging from 5.0 onwards, so there will the version difference of IE like MSIE 6.0..! or MSIE 5.5 some thing like that..
    any ways i will try with StringTokenizer once..!
    seems that will do my work..
    Thanks,
    krishna

  • Matching Regular Expressions in OBPM 10GR3

    Hi all,
    How do I match Regular expressions like" Wait For Response" in Strings using OBPM?
    Any idea?
    Is there any exact syntax?
    Because I tried doing this:-
    for( int i=0; i < testGroup.length(); i++)
         if(testGroup.reason.match(regexp : "Wait For Response"))
              logMessage("--Test Group Matched--");
    But it does not work..
    Any idea?

    String myVar = "has matching_char_set";
    if ( myVar.match(regexp : '/matching_char_set/') ) {
    logMessage("matched...yep");
    Try like this ..should work.
    Rgds,
    Biltu

  • Validate form entries: does java support regular expressions?

    i want to validate form entries, does java support regular express like javascript?

    Just recently in 1.4 regex was finally introduced :)
    Take a look at http://developer.java.sun.com/developer/technicalArticles/releases/1.4regex/

  • Phone number with regular expression

    Hi,
    is it possible to use regular expression for phone numbers?
    I want to create contacts for companies with several direct dial in numbers. My idea is to make one contact for the company itself with the base telephone number and a regular expression like an asterisk and separate contacts for person inside the company containing the direct dial in number.

    but a third-party app could not tell me who (anybody from the company or a special direct dial in number) is calling me at this very moment. So sounds like no way anyhow.

  • Allow specific characters - Regular Expression

    Hello everyone
    I am new to regular expression and I have a very simple question. I use the "read from text file" function to load a Tab delimited file with 3 columns into my VI. Next, the string is converted in array and I use the values.
    Nevertheless, I want to develop a "filter" allowing only digits (0-9), colon, comma and point into strings.
    Using the "match regular expression" function, I was trying a regular expression like that:
    [^0-9]|[^\].[|^:]|[^,]
    But it is not working.
    Could someone help me with this issue?
    Thanks
    Dan07
    Solved!
    Go to Solution.

    Hello
    Actually I don't need to modify the string that has "invalid" characters, I just need to identify them instead. Find below a VI testing both methods: Match Regular Expression and Search and Replace String.
    Using Match Regular Expression method, I got correct results since all the "valid" values must be identified as "-1" and all the "invalid" values must be identified as positive numbers (offset).
    Nevertheless, using Search and Replace String method I got wrong results, since all the strings were classified as "valid" (-1), but "bg" and "03/12/2010" are not "valid".
    I will go ahead with Match Regular Expression method because it is working great, but I was just wondering how to fix Search and Replace String method to achieve equivalent results.
    Thanks
    Dan07
    Attachments:
    Regular Expression_example.vi ‏18 KB

  • One question about Regular Expression!!!

    I need to creat such a regular expression to match the format "[ ][ ][ ]".
    For example, there is a context,
    (1), " The project manager defines [1][0.400][+goals] for iterations."
    Suppose that there are some spaces or "\n" characters in this way,
    (2), " The project manager defines [    1 ] [  0.400   ]
    [   +goals] for iterations."
    If the pattern match the format succefully, (2) strings should be replaced by (1)strings, in order words, the format of (1) is what I need finally,
    I had ever tried creating a regular expression likes \\[([^\n\s]]+)\\]\\[([^\n\s]]+)\\]\\[([^\n\s]]+)\\] , but it does not work well!
    DO YOU HOW TO IMPLEMENT IT IN JAVA?
    Thanks for your any reply!

    What I really need is that, via the regular
    expression, all the spaces and \n characters in
    square brackets [ and ], ] and [, will be thrown
    away.
    For example,
    Original:
    1) "The project manager defines [   1  ] [
    0.400 ]
    [   +goals] for iterations with the support"
    After matching:
    2) "The project manager defines [1][0.400][ [+goals]
    for iterations with the support"
    String 2) is what I need finally!
    Thanks for your any reply!Well I gave you the answer to that one already :-)
    If you need to preserve the spaces in between words use this one. I'm sure there's a better way to do it, I'm no RegEx master.
        public static void main(String[] args)
            String s = "[ 1 ] [ 0.400 ]\n[ +go als]";
            System.out.println( "Before: " + s );
            System.out.println( "\n\n" );
            s = s.replaceAll( "\\[\\s+", "[" );
            s = s.replaceAll( "\\s+\\]", "]" );
            s = s.replaceAll( "\\]\\s+\\[", "][" );
            System.out.println( "After: " + s );
        }

  • Quoted Regular Expression

    Hello All,
    I'm trying to use the RegExp class in a search routine, in
    which I want to match each word typed by a user to the start of a
    word in the text. This means I need a regular expression like
    /\bexpr/i for example, to match the word expression - well the
    start of it, anyway.
    The problem I have is taking the prefix entered by the user
    ("expr") and making it part of the regexp. Assuming the variable is
    userPrefix, I can do something like
    var re:RegExp = new RegExp("\\b" + userPrefix, "i");
    This works fine as long as the user doesn't type any magic
    characters. If the user types "\", for example, I'm left with an
    invalid RE. Java has a static method Pattern.quote(), or something
    like that, that takes the literal and makes it just a literal from
    the point of view of the regexp pattern compiler.
    Does anyone know if there's a similar utility for AS3?
    Thanks,
    Tim

    Hello All,
    I'm trying to use the RegExp class in a search routine, in
    which I want to match each word typed by a user to the start of a
    word in the text. This means I need a regular expression like
    /\bexpr/i for example, to match the word expression - well the
    start of it, anyway.
    The problem I have is taking the prefix entered by the user
    ("expr") and making it part of the regexp. Assuming the variable is
    userPrefix, I can do something like
    var re:RegExp = new RegExp("\\b" + userPrefix, "i");
    This works fine as long as the user doesn't type any magic
    characters. If the user types "\", for example, I'm left with an
    invalid RE. Java has a static method Pattern.quote(), or something
    like that, that takes the literal and makes it just a literal from
    the point of view of the regexp pattern compiler.
    Does anyone know if there's a similar utility for AS3?
    Thanks,
    Tim

  • ADF Regular expression Jspx page error

    Hi Friends
    Hi all i have requirement that my inputtext box may include charchters numbers and '&' as a special charchters
    so i written the below regular expression in validateRegExp tag
    <af:validateRegExp pattern="[a-zA-Z0-9&]" messageDetailNoMatch="Inproper text"/>
    but when i enter '&' char in the regex of the tag of my jspx page then it gives me compilier error, so is there any way to write the escape charachters in regular expression like '\ ' in java to avoid above problem.
    Thanks in advance
    Bipin patil
    Edited by: Bipin Patil on Aug 2, 2011 1:39 AM

    Hi..
    can you try with following
    for Ex: aA1& pattern
    ><af:inputText id="it1">
    ><af:validateRegExp pattern="[a-z][A-Z][0-9][&]" messageDetailNoMatch="Inproper text"/>
    ></af:inputText>
    for Ex: awerrAFDFDF12343&&& pattern(Every item should shown at least one time..)
    ><af:inputText id="it11">
    ><af:validateRegExp pattern="[a-z]+[A-Z]+[0-9]+[&]+" messageDetailNoMatch="Inproper text"/>
    ></af:inputText>
    Hope this will helpful..

  • Regular expression - Replace not like

    Hi All,
    Is there a regexp pattern to replace anything other than 'oracle' from the below string.
    "oracle sdsd oracle xyd fgh oracle idmdh asasas trtrt"
    The result will be "oracleoracleoracle"
    If I want to write like regexp_replace('oracle sdsd oracle xyd fgh oracle idmdh asasas trtrt',<pattern>), what should be the pattern?
    I know how to get the result by nesting regexp and other functions.
    But is there any single pattern for this?
    Thanks in advance.
    Note; This is not a business requirement, trying to learn regexp..

    884476 wrote:
    Could you please explain what does that pattern mean? We can look at your string as a sequence of substrings where each substring is set of characters (part A) followed by word oracle or, in last substring, by end-of-line (part B). Each of such substrings be want to replace with part B thus removing part A.
    Dot (.) means any character. Asterisk (*) means repeated 0 or more times. This is our part A (I'll get back to ? later). Pipe (|) means OR. Dollar sigh ($) means end-of-line. Parenthesis mean grouping. So ((oracle)|$) means string oracle or end-of line. This is our part B. Now back to question mark. By default Oracle regular expressions are "greedy". We say any character repeated any number of times followed by word oracle. Since word oracle itself matched definition of any character repeated any number of times (6 in this case) regexp will match it that way that it will be from the beginning of the string to last occurrence of word oracle - that's why it is called "greedy". Question mark (?) tells regexp not to use greedy matching, therefore '.*?oracle' will stop at first occurrence of word oracle. Now replacement string. Notation \1 is grouping backreference. Group 1 is ((oracle)|$) and, as I already noted, means string oracle or end-of line (whichever was found).
    SY.

  • Help in regular expression matching

    I have three expressions like
    1) [(y2009)(y2011)]
    2) [(y2008M5)(y2011M3)] or [(y2009M5)(y2010M12)]
    3) [(y2009M1d20)(y2011M12d31)]
    i want regular expression pattern for the above three expressions
    I am using :
    REGEXP_LIKE(timedomainexpression, '???[:digit:]{4}*[:digit:]{1,2}???[:digit:]{4}*[:digit:]{1,2}??', 'i');
    but its giving results for all above expressions while i want different expression for each.
    i hav used * after [:digit:]{4}, when i am using ? or . then its giving no results. Please help in this situation ASAP.
    Thanks

    I dont get your question Can you post your desired output? and also give some sample data.
    Please consider the following when you post a question.
    1. New features keep coming in every oracle version so please provide Your Oracle DB Version to get the best possible answer.
    You can use the following query and do a copy past of the output.
    select * from v$version 2. This forum has a very good Search Feature. Please use that before posting your question. Because for most of the questions
    that are asked the answer is already there.
    3. We dont know your DB structure or How your Data is. So you need to let us know. The best way would be to give some sample data like this.
    I have the following table called sales
    with sales
    as
          select 1 sales_id, 1 prod_id, 1001 inv_num, 120 qty from dual
          union all
          select 2 sales_id, 1 prod_id, 1002 inv_num, 25 qty from dual
    select *
      from sales 4. Rather than telling what you want in words its more easier when you give your expected output.
    For example in the above sales table, I want to know the total quantity and number of invoice for each product.
    The output should look like this
    Prod_id   sum_qty   count_inv
    1         145       2 5. When ever you get an error message post the entire error message. With the Error Number, The message and the Line number.
    6. Next thing is a very important thing to remember. Please post only well formatted code. Unformatted code is very hard to read.
    Your code format gets lost when you post it in the Oracle Forum. So in order to preserve it you need to
    use the {noformat}{noformat} tags.
    The usage of the tag is like this.
    <place your code here>\
    7. If you are posting a *Performance Related Question*. Please read
       {thread:id=501834} and {thread:id=863295}.
       Following those guide will be very helpful.
    8. Please keep in mind that this is a public forum. Here No question is URGENT.
       So use of words like *URGENT* or *ASAP* (As Soon As Possible) are considered to be rude.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for