Regular Expression back-reference Find/Replace in SQL Developer 4.0

I cannot seem to get the Search/Replace functionality to use back-references with Regular Expressions in 4.0.  This worked fine in 3.0.
Text in my editor:
abc
Example:
Find: (a)(bc)
Replace:
\1\1\1\2
Should result in:
aaabc
Instead I get:
\1\1\1\2
This still isn't fixed in 4.0.2 - I'll try to find time to put in MOS as a bug...

You know what, I think I'm logging in a sys on the command line on the sqlplus side of the house, AHA!
Wow, I must be tired....LOL...thanks

Similar Messages

  • Regular Expression back-reference in character class

    I am trying to capture quoted text (excluding the quotes) with the following pattern:
    "(['\"])([^\\1]+)\\1"
    The input string might look like:
    "That's strange"
    or:
    'valid "regex" pattern'
    I get an exception when trying to compile the pattern, because of the back-reference within character-class brackets: [^\1]
    This pattern worked with the org.apache.oro package. Is this a bug in the 1.4 Pattern class? Can you offer an alternative solution?
    Thanks,
    Tony

    Thanks for the reply. Apparently, my pattern wasn't working as I thought with ORO. The pattern you suggested, however, wouldn't do what I need either, because it would match anything between the first and last quote character. I don't want to match the string you included in your reply, because it includes the same quote character that encloses the entire string. If you think about my pattern again, you'll notice that the first capture group should match either a single or double quote character. Then the back-reference should be the exact character (single character) that was matched and captured. So the second capture group should be any number of characters, as long as they don't match the first capture group character, followed by the exact string matched in the first capture group (the single character). You probably are aware that when one or more characters are included in square brackets [], that it specifies a match of a single character that is found anywhere within that character class. So if the first capture group happened to match more than one character (impossible due to the pattern in that grouping), the following character class [^\1] should match any character EXCEPT any of the ones matched in the first capture group...right? There must be a bug in ORO that doesn't match correctly per my description, but it seems there is a bug in JDK 1.4 Pattern that will not even compile it. Just to re-iterate...if \1 matched "abc", [^\1] should match any single character EXCEPT a or b or c. I can get what I want, though, if I do it in 2 matches:
    Pattern pat = Pattern.compile("(['\"])(.*)");
    Matcher mat = pat.matcher(sText);
    mat.matches();
    String sQuote = mat.group(1);
    String sRem = mat.group(2);
    pat = Pattern.compile("([^" + sQuote + "]*)" + sQuote);
    mat = pat.matcher(sRem);
    mat.matches();
    String sWhatIWanted = mat.group(1);
    Thanks,
    Tony

  • [DW CC] Regular Expression and Back Reference in "Replace with": Escape

    I have a problem with escaping a character in "Replace with".
    Let's assume the following situation:
    Content:
    foobar
    Search for:
    (foo)(bar)
    Replace by:
    $1zot$2
    Result:
    foozotbar
    Everything is fine.
    But I want to insert the number "2" in between foo and bar.
    When I use
    Replace by: $12$2
    The result is:
    $12$2
    It seems that the regex engine interpretes the "$12" as a whole. And because there's no back reference with the count "12" DW cannot work correctly.
    The question:
    How can I "escape" the "2"?
    Thanks.

    Dreamweaver uses JavaScript for its Find and Replace with regex.
    I've just checked the Regular Expressions Cookbook by Jan Goyvaerts and Steven Levithan (O'Reilly). It deals with exactly this sort of situation where capturing groups can be ambiguous. This is what it says:
    "Java and JavaScript try to be clever with $10 [and above]. If a capturing group with the two-digit number exists in your regular expresssion, both digits are used for the capturing group. If fewer capturing groups exist, only the first digit is used to reference the group, leaving the second as a literal. Thus $23 is the 23rd capturing group, if it exists. Otherwise, it is the second capturing group followed by a literal 3."
    In other words, there is no way to escape the 2 in the Replace field. It would appear there's a bug in Dreamweaver's use of capturing groups.

  • Regular expression and pattern matching/replacing

    I have a list of key words. It has around 1000 key word now but can grow to 5000 keywords.
    My web application displays lot of texts which are stored in the database. My requirement is to scan each text for the occurance of any of the above keywords. If any keyword is present I have to replace that with some custom values, before showing it to the user.
    I was thinking of using using regular expression for replacing the keyword in the text using matcher.replaceAll method as follows:
    Pattern pattern = Pattern.compile(patternStr);
    Matcher matcher = pattern.matcher(inputStr);
    String output = matcher.replaceAll(replacementStr);
    But My pattern string will have around 5000 keywords with the 'OR' Logical Operator like- keyword1| keyword2 I keyword3 | ..........
    Will such a big pattern string adversly affect the performance? What can I do to speed up the performance? (Since my keyword list is not static i would prefer to do the replacement just before showing the text to the user)
    Any suggestions are most welcome.

    I don't think a pure regex approach would be that slow, but it would be a maintenance nightmare. I think a combined regex/table-lookup approach would be best: use a regex to identify potential keywords, then look them up in the table to confirm. For instance, to find all Java keywords you could use the regex "\\b[a-z]{2,12}+\\b" to filter out anything that can't possibility be a keyword.
    What are you going to replace the keywords with? Will it vary depending on which keyword is found? If so, you'll have to use a table--and you won't be able to use the replaceAll method, because it can't handle dynamically generated replacement values. You would have to use the lower-level appendReplacement and appendTail method instead.

  • Regular Expressions... finding a '('

    Hi guys,
    Been trying for an hour or so now, but i can't seem to find out how to locate a "(" in a regular expression and the usuall break out characters '\\' doesnt seem to work..
    I.e. in the text that I'm searching, the string I want to scrape out may sometimes contain a " ( .* ) " at the end of it, so I've been writing regex's like
    ([A-Z]) ([a-z]*) ([_]?) ([\\([? )    //more follows
    I hope that's clear.. its the last part with the '(' that doesnt work..
    o.0
    ___

    tried the double backslash.. and still doesn't work.. here's the actual regex I'm writing;
    pattern = Pattern.compile("((href=\"/wiki/)([A-Z])([a-z]*)(_)([A-Z])([a-z]*)([A-Z]?)([a-z?]*)([_]?)([\\(]?)", Pattern.MULTILINE);{code}
    Edited by: Mark.ONeill on Jan 2, 2008 12:47 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Regular Expression - replaceAll() - how to replace words?

    Hiya,
    I have this regex to replace all instances of myWord:
    String oldWord = "oldWord";
    String newWord = "newWord";
    String sentence = "some sentence that contains " + oldWord;
    String newSentence = replaceWordsInSentence(sentence, oldWord, newWord);
    private String replaceWordsInSentence(String sentence, String oldWord, String newWord) {
        return sentence.replaceAll("\b" + oldWord + "\b", newWord);
    }...it works in most instances, but when oldWord is at the end of the sentence it is not replaced. Presumably the problem is that "/b" is not a sufficient word boundary. Can someone help me out with the correct regular expression code?
    Thanks,
    James

    Mel, you did appear to misunderstand as you thought points 2 and 3 were alternatives, but you now recognise that they are additional "shoulds".
    Of course, I applied the extra backslash as soon as Joachim advised. Maybe you don't agree with my rationale, but I prefer the complete solution that will work in all instances... so was simply waiting for him to post a code example that included the latter 2 points as (although I understood the point of them perfectly) I was not sure how to implement them.
    Have come up with the following, expanded, method...
        private String replaceWordsInSentence(String sentence, String oldWord, String newWord) {
            return sentence.replaceAll("\\b" + Pattern.quote(oldWord) + "\\b", Matcher.quoteReplacement(newWord));
        }...works fine with the tests I have run. Joachim, can you confirm this is correct.

  • Linux, Oracle Databace 10g Express Ed installation so can run SQL Developer

    Dear Oracle
    I am endeavouring to run SQLDeveloper for Linux on my Netbook running Ubuntu 11.04 'Natty Narwhal' OS on an i386 architecture and have not yet been successful. I am doing this as we are using SQL Developer in my Computer Science undergraduate studies at RMIT in Melbourne, Australia. I first followed the cursory instructions on your site where I agreed to the Terms & Conditions of your license and downloaded the SQLDeveloper for Linux package. I have been tinkering with it but I can't get it to execute and open.
    I then did some research on the Internet to solve this problem and found a website from a Linux user that had codified the process they went through to get SQL Developer to work. I have included a copy of the website URL for your reference:
    [http://www.kodiaktechnical.com/wordpress/?p=84|http://www.kodiaktechnical.com/wordpress/?p=84]
    I have been working through the steps of this process and one of them was to install another one your, that is Oracle's, applications/tools which is: oracle-xe_10.2.0.1-1.0_i386.deb
    On running this Debian installation package for Linux my Ubuntu system opened a dialogue box which related:
    "The package is of bad quality
    The installation of a package which violates the quality standards isn't allowed. This could cause serious problems on your computer. Please contact the person or organisation who provided this package file and include the details beneath.
    Details:
    Lintian check results for /tmp/oracle-xe_10.2.0.1-1.0_i386.deb:
    E: oracle-xe: file-in-usr-marked-as-conffile usr/lib/oracle/xe/app/oracle/product/10.2.0/server/network/admin/listener.ora
    E: oracle-xe: file-in-usr-marked-as-conffile usr/lib/oracle/xe/app/oracle/product/10.2.0/server/network/admin/tnsnames.ora
    E: oracle-xe: file-in-usr-marked-as-conffile usr/lib/oracle/xe/app/oracle/product/10.2.0/server/config/scripts/postDBCreation.sql
    E: oracle-xe: file-in-usr-marked-as-conffile usr/lib/oracle/xe/app/oracle/product/10.2.0/server/config/scripts/init.ora
    E: oracle-xe: file-in-usr-marked-as-conffile usr/lib/oracle/xe/app/oracle/product/10.2.0/server/config/scripts/initXETemp.ora"
    This dialogue box had two button options <<OK>> and <<Ignore and install>>. I have tried both but no success.
    I would really appreciate some assistance.
    Thanking you in anticipation
    Beauford

    Hi,
    Most of ppl in this forum are not from Oracle.
    Please try install XE database from repository. Follow these instructions.
    http://www.debian-administration.org/articles/430
    Regards,
    Jari

  • Where to find help with SQL Developer installation?

    Hi,
    I just want to try out SQL Developer and compare its capabilities to TOAD's. Unfortunately, I am not PC software savvy and now am stuck with a SQL Developer (sqldeveloper-1.2.2998) installation problem. When I clicked on the .exe file, I got a blank SQL Developer screen - there is nothing in the screen except a heading that reads 'Oracle SQL Developer'...
    Does anyone know of a blog or a site that I can get some help with problems like mine?
    Any help is much appreciated!

    Hi,
    SQL Developer forum link:
    "http://forums.oracle.com/forums/forum.jspa?forumID=260"
    There are 2 versions of SQL Developer, with/without JRE.
    Try out the full install version with JRE.
    HTH
    Zack

  • Regular Expression -- Did Not Find Successfully

    I ran a test: to find a piece of text "Bill" in a letter. This letter is in MS Word format. I am certain that "Bill" is in the letter. My simple java program compiled and ran (java MatchingText). However, I did not get "A match is found", which is the message specified in the System.out.println, to the console.
    Here is my code:
    import java.util.regex.*;
    import java.io.*;
    public class MatchingText {
    public static void main(String[] args) throws Exception {
    File fin = new File("c:/javaprj/letter.doc");
    //Open an input stream
    FileInputStream fis =
    new FileInputStream(fin);
    BufferedReader in = new BufferedReader(
    new InputStreamReader(fis));
    String input = "Bill";
    // Create a pattern to match input
    Pattern p = Pattern.compile("input");
    Matcher m = p.matcher(input);
    if (m.find()) {
    System.out.println("A match is found"); }
    in.close();
    Could someone points out my mistake? Thanks.

    There were mistakes in my program. I fixed some of the mistakes and I could see improvements in the output. Yet, I am not quite there:
    when there is no match in the source document, the code outputs "Found A Match" twice to the console.
    When there is "one" match in the source document, the code outputs "Found A Match" three times to the console.
    When there are "two" matches in the source document, the code outputs "Found A Match" four times to the console.
    When there are "three" matches in the source document, the code outputs "Found A Match" five times to the console.
    and so on.
    Just wonder where those two extra "Found A Match" come from.
    code:
    import java.util.regex.*;
    import java.io.*;
    public class MatchingText {
    public static void main(String[] args) throws Exception {
    //String provided by the user
    String userInput = "Bill";
    File fin = new File("c:/javaprj/letter.doc");
    //opens a bufferdReader to read lines
    BufferedReader in=new BufferedReader(new FileReader(fin));
    try {
    while((userInput = in.readLine()) !=null) {
    //pattern in the source document
    String targetText = "Bill";
    //Create a pattern to match input
    Pattern p = Pattern.compile(targetText);
    //To find a match in each line
    Matcher m = p.matcher(userInput);
    while (m.find()) System.out.println("Found A Match");
    catch(IOException e){System.out.println("Error occurred while reading!");}
    //close the streams
    finally {
    try {
    in.close();
    catch(IOException e){System.out.println("closing file exception");}
    --------------------------------------------------

  • Finding a PL/SQL developer

    For those of you who have to select, or participate in selecting, PL/SQL developers, how do you know a really good one when you see him. I am not so much interested in ancillary skills like process modeling, data design, and so forth. I am only interested, at the moment, in PL/SQL skills. What traits tell you this one is a real winner and that one is lacking? Do you use practical questions, a quiz, request to look at sample code?
    And, if you can manage to tell the wheat from the chaff, can you also tell who has real promise - those that could become great with a bit of time and mentoring - from those who will likely never be very good?

    Hi AJ,
    how do you know a really good one when you see himThey tend to look like this:
    http://stevenfeuerstein.com/images/stevenf.jpg
    Do you use practical questions, a quiz, request to look at sample code?I have, but coding is such a personal style, that I prefer to use employer referrals instead. You are always allowed to ask any previous employer "would you re-hire this person", and the answer says a lot!
    But seriously, there are some books that have questions to ask PL/SQL developers:
    http://www.google.com/search?&q=pl%2Fsql+job+interview+book
    And, if you can manage to tell the wheat from the chaffPersonally, interpersonal skills are sometimes as important as coding skills. Here is how I do it. First, I take them golfing, that says a lot about their ability to play well with others:
    http://www.dba-oracle.com/golf_travel/golfing_job_interview.htm
    This article is very good, IMHO:
    http://msdn.microsoft.com/Longhorn/default.aspx?pull=/library/en-us/dnsoftware/html/software07072004.asp
    "It is much better to reject a good candidate than to accept a bad candidate. ... If you have any doubts whatsoever, No Hire."
    A good manager should know to look for the seriously focused individual, one who wants to constantly educate themselves:
    When I evaluate a candidate, one of the most important criteria is what I call "the first derivative". Is this person learning? Is this candidate moving forward, or have they stagnated?"
    Hope this helps. . .
    Donald K. Burleson
    Oracle Press author
    Author of "Oracle Tuning: The Definitive Reference":
    http://www.dba-oracle.com/bp/s_oracle_tuning_book.htm

  • Grouping & Back-references with regular expressions on Replace Text window

    I really appreciate the inclusion of the Regular Expressions in the search & replace feature. One thing I am missing is back-references in the replacement expression. For instance, in the unix tools vi or sed, I might do something like this:
    s/\(firstPart\) \(secondPart\) \(oldThirdPart\)/\2 \1 newThirdPart/g
    which would allow me to switch the places of firstPart and secondPart, and totally replace thirdPart. If grouping and back-references are already present in the Replace Text window, how does one correctly invoke them?

    duplicate of Grouping & Back-references with regular expressions on Replace Text window

  • Java – Regular Expressions – Finding any non digit byte in a multiple byte

    Hello,
    I’m new to JAVA and Regular Expressions; I’m trying to write a regular expression that will find any records that contain a non digit byte in a multiple byte field.
    I thought the following was the correct expression but it is only finding records that contain “all” non digit bytes.
    \D{1,}
    \D = Non Digit
    {1,} = at least 1 or more
    Below is my sample data. I would like the regular expression to find all of the records that are not all numeric. However when I use the regular expression \D{1,} it is only finding the 2 records that all bytes are non digits. (i.e. “ “ and “A “)
    “ 111229”
    “2 111229”
    “20091229”
    “200912c9”
    “201#1229”
    “20101229”
    “20110229”
    “20111*29”
    “20111029”
    “20111229”
    “20B11229”
    “A “
    “A0111229”
    Please note I have also tried \D{1,}+ and \D{1,}? And they also do not return my desired results
    Any assistance someone can provide would be greatly appreciated.

    You don't show the code you are using but I surmise you are using String.matches() which requires that the whole target must match the regular expression not just part of it. Instead you should create a Pattern and then a Matcher and use the Matcher.find() method. Check the Javadoc for Pattern and Matcher and look at the Java regex tutorial - http://docs.oracle.com/javase/tutorial/essential/regex/ .
    P.S. You can re-use the Pattern object - you don't have to create it every time you need one.
    P.P.S. Java regular expressions work with characters not bytes and characters are not not not bytes.

  • Regular Expressions - Removing a Timestamp?

    I have hundreds of plain HTML pages. I'd like to remove the
    timestamp from them, which looks like this:
    [19:45]
    I've tried using the wildcard feature, but the problem is is
    that I want the BRACKETS gone, as well. Unfortunately, I've only
    succeeded in removing either the last bracket (with the open
    bracket and time still intact) or all of my data completely. How
    can I successfully delete the varying times and their brackets
    without touching the rest of my data?

    In Find/Replace, with Use Regular Expression turned on:
    Find:
    \[\d\d?:\d\d?\]
    Replace:
    (leave it blank)
    E. Michael Brandt
    www.divahtml.com
    www.divahtml.com/products/scripts_dreamweaver_extensions.php
    Standards-compliant scripts and Dreamweaver Extensions
    www.valleywebdesigns.com/vwd_Vdw.asp
    JustSo PictureWindow
    JustSo PhotoAlbum, et alia

  • Regular Expression for Removing a space after the a... tag?

    Hi there,
    I'm fairly new to using Regular Expressions, but am in need of one that will help me find all <a...> tags that have a space immediately following that tag and replace it with the exact same tag, but no space following the <a...> tag.
    So, for example, a regular expression that will find:
    <a href="somelink.html"> Somelink</a>
    as well as:
    <a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('sub-nav_button_professional_portal','','images/sub-nav_button_ professional_portal_f2.png',1)"> Somelink</a>
    And just remove the space appearing as part of the hyperlink.  Does anyone know how to accomplish this?

    Thought of that, but it would remove spaces from crucial areas of my pages.  For example, conditional logic within a script, like:
    for (i = 0; i > (a.length - 2); i += 3)
    would become:
    for (i = 0; i >(a.length - 2); i += 3)
    While that wouldn't pose a huge problem, I'm messing up the syntax in order to fix something else, which is why I wanted to go the route of a regular expression.  I need to replace all "<a ...> " (space included) tags with "<a ...>" and make sure that the properties within the <a> tag stay in tact.

  • Carriage Return - Regular Expression

    Hi guys,
    I'm looking for an effective method to speed up the extreme optimization process in my work (finally to not do it manually).
    The particulary issue is to find a good regular expression to replace the carriage returns in the source code with nothing.
    I searched on the net, and many sources converge on the RegExr tool: http://gskinner.com/RegExr/
    I tried to set up an expression to solve my problem but it doesn't work. The expression that was generated by the tool is:
    Find: /\r/g Replace: (none) 
    When i enter the expression in Dreamweaver Find & Replace panel (with regular expression option checked and match case, etc. unchecked), it seems to not produce any valid change on the code.
    I'm sure that i'm wrong something.
    Anyone have suggestion?
    Thanks all for help.

    I don't understand the point of this.  There's very little to be gained from removing white space from code. And if you do this to JavaScript, you'll very likely break the code.
    Safer method, go to Edit > Preferences > Code Format > click on Tag Libraries and define how you want your code formatted.  Then  apply with Command > Apply Source Formatting.
    Nancy O.

Maybe you are looking for