Back reference for regular expressions on "Search & Replace".

Can't I reference a result from my Regular Expression used on "Search Clause" into my "Replace Clause"?
What I'm doing is:
Using JDev 10.1.3 DP,
Search Menu -> Replace in Files...
Select "Regular Expressions"
Text: (A[0-9]*?_)(.)
Replace with: $2 (reference to the second Parenthesis in the "Text" Field).
For example, in Java, I would so something like this:
"Dummy String".replaceAll("(D.*? )(S)", "$2");
Are there any other ways that I can just Search something and Replace for nothing? I need a simple "Search and Delete", you know?
If I don't do that and try to leave it blank, a warning comes up saying that the "Replace with" field cannot be blank.
Any sugestions?

BOUNCE!
Please, anyone?
Will I really have to delete 1200 occurrences by hand???
:(

Similar Messages

  • 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

  • Can somebody help me in getting some good material for Regular Expressions and IP Community list

    can somebody help me in getting some good material for Regular Expressions and IP Community list

    I'm not sure what you mean by "IP Community list", but here are 3 reference sites for Regular Expressions:
    Regular Expression Tutorial - Learn How to Use Regular Expressions
    http://www.regular-expressions.info/tutorial.html
    Regular Expressions Cheat Sheet by DaveChild
    http://www.cheatography.com/davechild/cheat-sheets/regular-expressions/
    Regular Expressions Quick Reference
    http://www.autohotkey.com/docs/misc/RegEx-QuickRef.htm

  • Regular Expressions find and replace

    Hi ,
    I have a question on using Regular Expressions in Java(java.util.regex).
    Problem Description:
    I have a string (say for example strHTML) which contains the whole HTML code of a webpage. I want to be able to search for all the image source tags and check whether they are absolute urls to the image source(for eg. <img src="www.google.com/images/logo.gif" >) or relative(for eg. <img src="../images/logo.gif" >).
    If they are realtive urls to the image path, then I wish to replace them with their absolute urls throughout the webpage(in this case inside string strHTML).
    I have to do it inside a servlet and hence have to use java.
    I tried . This is the code. It doesn't match and replace and goes inside an infinite loop i.e probably the pattern matches everything.
    //Change all images to actual http addresses FOR example change src="../images/logo.gif" to src="http://www.google.com/../images/logo.gif"
              String ddurl="http://www.google.com/";
    String strHTML=" < img src=\"../images/logo.gif\" alt=\"Google logo\">";
    Pattern p = Pattern.compile ("(?i)src[\\s]*=[\\s]*[\"\']([./]*.*)[\"\']");
    Matcher m = p.matcher (strHTML);
    while(m.find())
    m.replaceAll(ddurl+m.group(1));
    what is wrong in this?
    Thanks,
    Rajiv

    Right, here's the full monte (whatever that means):import java.util.regex.*;
    public class Test1
      public static void main(String[] args)
        String domain = "http://www.google.com/";
        String strHTML =
          " < img src=\"images/logo.gif\" alt=\"Google logo\">\n" +
          " <img alt=\"Google logo\" src=images/logo.gif >\n" +
          " <IMG SRC=\"/images/logo.gif\" alt=\"Google logo\">\n" +
          " <img alt=\"Google logo\" src=../images/logo.gif>\n" +
          " <img src=http://www.yahoo.com/images/logo.gif alt=\"Yahoo logo\">";
        String regex =
          "(<\\s*img.+?src\\s*=\\s*)   # Capture preliminaries in $1.  \n" +
          "(?:                         # First look for URL in quotes. \n" +
          "   ([\"\'])                 #   Capture open quote in $2.   \n" +
          "   (?!http:)                #   If it isn't absolute...     \n" +
          "   /?(.+?)                  #    ...capture URL in $3       \n" +
          "   \\2                      #   Match the closing quote     \n" +
          " |                          # Look for non-quoted URL.      \n" +
          "   (?!http:)                #   If it isn't absolute...     \n" +
          "   /?([^\\s>]+)             #    ...capture URL in $4       \n" +
        Pattern p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE | Pattern.COMMENTS);
        Matcher m = p.matcher(strHTML);
        StringBuffer sbuf = new StringBuffer();
        while (m.find())
          String relURL = m.group(3) != null ? m.group(3) : m.group(4);
          m.appendReplacement(sbuf, "$1\"" + domain + relURL + "\"");
        m.appendTail(sbuf);
        System.out.println(sbuf.toString());
    }First off, observe that I'm using free-spacing (or "COMMENTS") mode to make the regex easier to read--all the whitespace and comments will be ignored by the Pattern compiler. I also used the CASE_INSENSITIVE flag instead of an embedded (?i), just to remove some clutter. By the way, your second (?i) was redundant; the first one would remain in effect until "turned off" with a (?-i). Another way to localize a flag's effect by using it within a non-capturing group, e.g., (?i:img).
    As jaylogan said, the best way to filter out absolute URL's is by using a negative lookahead, and that's what I've done here. The problem of optional quotes I addressed by trying to match first with quotes, then without. The all-in-one approach might work with URL's, since they can't (AFAIK) contain whitespace anyway, but the alternation method can be used to match any attribute/value pair. It's also, I feel, easier to understand and maintain. Unfortunately, it also means that you can't use replaceAll(), since you have to determine which alternative matched before doing the replacement, but the long version is still pretty simple (especially when you can just copy it from the javadoc for the appendReplacement() method, as I did).

  • "Multiple Line" Regular expressions in find/replace

    Hi there,
    I'm wondering if it is possible to find and replace (in batch
    mode) the following obstacle:
    say is have this piece of code in every html file i'd like to
    edit:
    <html>
    <blah blah (Same text in all files)>
    <blah blah (NOT same text in all files)>
    <blah blah (NOT same text in all files)>
    <code that is the same again in all files>
    and would like to replace it by nothing, effectively deleting
    the part completely... (by leaving the replace by field empty).
    The tricky part is that the lines which are NOT the same in
    all files, are sometimes 2 lines, but sometimes 3 or more lines.
    Somehow I need to get the regular expression to include
    <line>* (or something similar), in order to make the regular
    expression work.
    Any ideas on how to solve this? I must say untill now, the
    Dreamweaver search and replace function has been the most effective
    one, compared to many alternatives out there.
    Rp

    I've tried \1 and $1Just these in the text items of the find & replace dialog box...?????
    Can you write down exactly what have you tried....(text to be replaced by which....)????
    Greetings....
    Sim

  • Regular Expression Find and Replace with Wildcards

    Hi!
    For the world of me, I can't figure out the right way to do this.
    I basically have a list of last names, first names. I want the last name to have a different css style than the first name.
    So this is what I have now:
    <b>AAGAARD, TODD, S.</b><br>
    <b>AAMOT, KARI,</b> <br>
    <b>AARON, MARJORIE, C. </b> <br>
    and this is what I need to have:
    <span class="LastName">AAGAARD</span>  <span class="FirstName">, TODD, S. </span> <br />
    <span class="LastName">AAMOT</span> <span class="FirstName">, KARI,</span> <br/>
    <span class="LastName">AARON</span> <span class="FirstName">, MARJORIE, C.</span> <br/>
    Any ideas?
    Thanks!

    Make a backup first.
    In the Find field use:
    <b>(\w+),\s+([^<]+)<\/b>\s*<br>
    In the Replace field use:
    <span class="LastName">$1</span> <span classs="FirstName">$2</span><br />
    Select Use regular expression. Light the blue touch paper, and click Replace All.

  • Regular expressions-how to replace [ and ] characters from a string

    Hi,
    my input String is "sdf938 [98033]". Now from this given string, i would like to replace the characters occurring within square brackets to empty string, including the square brackets too.
    my output String needs to be "sdf938" in this case.. How should I do it using regular expressions? I tried several possible combinations but didn't get the expected results.

    "\\s*\\[[^\\]]+\\]"

  • Please recommend a good tutorial for Regular expressions?

    I have several PERL programs that I need to translate in to JAVA for performance reasons. Those programs heavily use Regular Expressions. I have an excellent knowledge about PERL Regular Expressions but know very little about Java Regular Expressions.
    So Can any one of you recommend me a good tutorial for Java Regular Expressions.
    Thankx In Advance
         LRMK

    Since you know regexs, the java.util.regex.Pattern class API is probably all you need, it pretty thoroughly documents Java's flavor, and the differences from PERL's flavor.

  • Mining for regular expressions from text

    Hi all
    I have a situation where I need to develop a set of regular expressions from lists.
    I have lists of files uploaded and downloaded, and when the event happened. I need to analyze these and boil them down to a set of regular expressions.
    The regular expressions will be used in the future to check the logs for activities. For example:
    foo*.zip is downloaded every night. Has it been downloaded tonight.
    I am looking for help in analyzing the lists of files and deriving regular expressions to describe them.
    Any ideas?
    Thanks all

    check the url http://java.sun.com/developer/technicalArticles/releases/1.4regex/index.html

  • How to set keepalive check for regular expression

    Hi
    We are using css110501 CSS.
    Right now the keepalives on services are set using hash values.
    But i want to change this keepalives to implement keepalives with regular expression checking.
    Any Ideas?

    The CSS supports it's own native scripting language that can be used to write keepalives among other things.
    Here is an example of a script that I wrote to check a page for some specific text:
    ! Filename: ap-kal-statpage
    ! Parameters: None - must be coded in script
    ! Description:
    ! This script will attempt to connect to a host and
    ! "GET" an html page. The script checks the contents
    ! of the page for a particular string. If the string
    ! is found, the script passes.
    ! Failure Upon:
    ! 1. The correct arguments are not supplied.
    ! 2. The CSS is unable to connect to the host.
    ! 3. The string is not found in the page.
    no echo
    if ${ARGS}[#] "LT" "4"
    echo "Usage: ap-kal-portlist \'Hostname Port Page String ...\'"
    exit script 1
    endbranch
    set host "${ARGS}[1]"
    set port "${ARGS}[2]"
    set page "${ARGS}[3]"
    set string "${ARGS}[4]"
    set EXIT_MSG "Host ${host} not responding on TCP port ${port}."
    socket connect host ${host} port ${port} tcp
    socket send ${SOCKET} "GET ${page} HTTP/1.0\n\n"
    set EXIT_MSG "String was not found."
    socket waitfor ${SOCKET} "${string}" 200
    socket disconnect ${SOCKET}
    echo "String ${string} was found."
    no set EXIT_MSG
    exit script 0

  • Java parser for regular expression to java program

    Hi All,
    I am very new to parser technologies .I am looking for a (java)parser which can read the "regular expression" and can convert it into "java program".Please let me know is there any thing related to this.
    Thanks in advance.
    Your will be appriciate.
    Regards,
    Sai.

    Hi Jos,
    Thank you for your quick response .You're welcome.
    If you have any sample code or simple example for how to use those
    classes (Pattern,Match) ,will you please send me .It will be helpful for me.Jverd gave you two nice links already in his reply #3
    If there is any "open source" for parsering regular expressions.
    Please send me I am very new to parser technologies.Note that that Pattern class take care of all the parsing of REs, i.e. there's
    nothing 'interesting' left for you to do any parsing whatsoever. Can you
    elaborate a bit on what you exactly want to do and learn?
    kind regards,
    Jos

  • Validation for regular expressions special characters in java

    Hi,
    I need to validate an user name field to an application while creating that. It has to contain only alpha numerics. can you give me the regular expression and also how to implement that.
    thanks,
    VJ

    Do your own work. Look up the documentation on Pattern and make an attempt at validating a String yourself. Then worry about implementing a GUI on top of that.

  • Regular Expression to Search Comma Delimited File for any of 3 Values

    Hi,
    I'd like to parse a table column that contains a comma delimited string for any of 3 values, 1200, 1400, 1600 just to see if they're present using Regexp_instr. If someone has an expression available please pass it along.
    Thanks,
    Victor

    Or you could do it like this too...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 1 as id, '1000,2000,3000' as txt from dual union all
      2             select 2, '1200,1300,1400' from dual union all
      3             select 3, '1000,1300,1600' from dual)
      4  -- end of test data
      5  select *
      6  from t
      7* where regexp_like(txt,'(^|,)(1200|1400|1600)(,|$)')
    SQL> /
            ID TXT
             2 1200,1300,1400
             3 1000,1300,1600

  • Regular expression to search if a word occurs with z and /z tags

    Hi ,
    I am trying to create a regex to search for the occurence of two words within <z> and </z> tags.(they must occur between <z> and and next immideate </z> tags)
    This is my regex
    <z>\s[\w\W]+?(?!</z>)word1[\w\W]+?(?!</z>)word2[\w\W]+?</z>|<z>\s[\w\W]+?(?!</z>)word2[\w\W]+?(?!</z>)word1[\w\W]+?</z>
    I am trying to specify (?!</z>) in order that i insist that my regex engine does map for word1 and word2 within <z> and its next immideate </z> tags. The words can appear either ways word1 followed by word2 or vice versa.
    The above regex does not work fine.
    It maps fine for the following sentence
    <z> This is test for pattern for a Regex </z> <z> Also we would like to conclude what is happening </z> <z> Another test for paragraph is happening </z>
    The regex is as follows
    <z>\s[\w\W]+?(?!</z>)pattern[\w\W]+?(?!</z>)Regex[\w\W]+?</z>|<z>\s[\w\W]+?(?!</z>)Regex[\w\W]+?(?!</z>)pattern[\w\W]+?</z>
    But, when i include the </z> in between pattern and Regex , it should not match, but that is not what is happening.
    <z> This is test for pattern </z> for a Regex</z> <z> Also we would like to conclude what is happening </z> <z> Another test for paragraph is happening </z>
    Please let me know how I can accomplish the same.
    Thanks.

    oops.. sorry ..this is aligned better ...
    Hi , I am using this regex
    (?=(?:(?!</z>).)+?\bpattern\b.+</z>)(?!(?:(?!</z>).)+?\bscientific\b.+</z>)((\bpattern\b(?:(?!</z>).)+)\bpattern\b|\bpattern\b)I have written the above regex to match pattern between <z> and </z> provided there is no word "scientific" within that "z" tags.
    I have been trying to replace the regex to do the same between two sentences, here in my case I have a paragraph with multiple sentences. The delimiter to determine a sentence is dot (.). So i am trying to specify the condition as above to match between two sentences - using representation for dot as (\. )
    The following is my regex
    (?=(?:(?!\.).)+?\bpattern\b.+\.)(?!(?:(?!\.).)+?\bscientific\b.+\.)((\bpattern\b(?:(?!\.).)+)\bpattern\b|\bpattern\b) But this does not work..
    Can you please tell me how to go about this?
    Thanks.

  • Regular Expression + Find and Replace

    Hey there-  I have a question about regExp and the Find and Replace.  Basically I want to search a wildcard between a href tag, how would that look, because the code below does not work.
    countryLink = "<a href=\"http://www.whateve.com\" target=\"_parent\">";
    [code]
    countryLink = "([^"]*)";
    [code]
    Thanks! Any help is appreciated!
    Also, how do i add code blocks to this forum?

    Yes, I meant the <a> tag, but thank you for displaying the href attribute solution as well.  This solved my issue.  Thanks!  Thought I would display what I did with your code incase someone was interested in using this code to convert a javascript string to XML.
    query this:
    countryLink = "<a href=\"http://www.whateve.com\" target=\"_blank\">";
    add this to the Find box:
    countryLink = "<a href=\\"([-\w:/.?=&;]+)\\" target=\\"_parent\\">";
    add this to the Replace box:
    <countryLink>$1</countryLink>
    creates an output of this:
    <countryLink>http://www.whateve.com</countryLink>

Maybe you are looking for

  • Statistical and noted item

    Hi, May I know if there is a difference between statistical posting (like F-38 statistical posting and F-19 for reversal statistical) and noted item (F-47). I know that noted item only create 1 line and able to track in line item display whereas stat

  • Setting up an iPad in Argentina?

    A friend in Argentina would like an iPad Mini.  What is the best way to set up the Apple ID for international use?  They do not intend to link a credit card to the account.  Can an Apple ID be set up without a credit card and can iTunes/Apple gift ca

  • Problem with convert

    i use se38 to send data to sapscript i have this statemaent WHEN 'KOMK-FKWRT'. move in_tab-value to zXXXXX. if i have a number 1,999.00 i have dump. i need FM??? what is it???

  • Automatically copy format to new slide

    HI all, I'm new with Keynote and I'm sure there is an easy answer to this, but I certainly can't seem to find it. I'm putting together a boring, bulleted presentation and have adjusted the master slide to the format I want. Changed font, size, bullet

  • Unable to get updates. Error code 80070246. Attempted to download "fix".

     Cannot get updates. Attempting to get them shows error code 80070246. While attempting to solve problem, I downloaded the KB (something) fix on the help site, which resulted in (no kidding) 21 HOURS of downlaoding, 40 minutes of installing and a rea