HTML Escaping Regular Expression

Assume I have the following string:
<font face="arial">this</font> is a <b>very nice</b> " <a href>String</a>Now say I want to allow everything above, except I want to escape certain tags... IE I want to allow:
<b>,</b>,<font ...>,</font> and nothing else. The escaped string above should then be converted to:
<font face="arial">this</font> is a <b>very nice</b> " & lt;a href & gt; String & lt;/a& gt;The idea I'm trying to implement is to allow form input that may contain limited html tags, that I define, and escape anything else.
This seems like it would be an existing regular expression, does anyone have any ideas?
Thanks!

Kudos and thanks for the regex. I did not know how to do negation in a regular expression, ie (?!FONT|B)To answer an earlier post, the application works much like a message board. I accept input from a textarea, then write that input out as an html file (much like how this forum works). I'd like to accept certain HTML markup in the input, but disallow tags like "<javascript>", "<object>" and "<embed>", etc, as writing those tags would allow users to post malicious input (redirects, popups, etc). Thus, defining and parsing what tags I will accept is easier than defining the tags not to accept (and safer).
That being said, escaping quotes is somewhat important, as " in html that is not in a tag should really be the converted to & quot; for w3c browser standards. However, with 95% of my original question answered (that being the most important part), I'm satisfied with this. Thanks to all for the help thus far!

Similar Messages

  • Rplacing space with &nbsb; in html using regular expressions

    Hi
    I want to replace space with &nbsb; in HTML.
    I used  the below method to replace space in my html file.
    var spacePattern11:RegExp =/(\s)/g; 
    str= str.replace(spacePattern," "
    Here str varaible contains below html file.In this html file i want to replace space present between " What number does this  represents" with &nbsb;
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    <b><TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" style = 'font-size:10px' COLOR="#0B333C" LETTERSPACING="0" KERNING="0"><B></B></FONT></P></TEXTFORMAT><TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" style = 'font-size:10px' COLOR="#0B333C" LETTERSPACING="0" KERNING="0"><B> What number does this Roman numeral represents MDCCCXVIII ?</B></FONT></P></TEXTFORMAT></b>
    </body>
    </html>
    But by using the above regular expression i am getting like this.
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head><body>
    <b><TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" style = 'font-size:10px' COLOR="#0B333C" LETTERSPACING="0" KERNING="0"><B></B></FONT></P></TEXTFORMAT><TEXTFORMAT LEADING="2"><P A LIGN="LEFT"><FONT FACE="Verdana" style = 'font-size:10px' COLOR="#0B333C" LETTERSPACING="0 " KERNING="0"><B> What number does this represents</B></FONT></P></TEXTFORMAT></b>
    </body>
    </html>
    Here what happening means it was replacing space with &nbsb; in HTML tags also.But want to replace space with &nbsb; present in the outside of the HTML tags.I want like this using regular expressions in FLEX
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>What number does this represents</body>
    </html>
    Hi,Please give me the solution to slove the above problem using regular expressions
    Thanks in Advance to all
    Regards
    ssssssss

    sorry i missed some information in above,The modified information was in red color
    Hi
    I want to replace space with &nbsb; in HTML.
    I used  the below method to replace space in my html file.
    var spacePattern11:RegExp =/(\s)/g; 
    str= str.replace(spacePattern," "
    Here str varaible contains below html file.In this html file i want to replace space present between " What number does this  represents" with &nbsb;
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    <b><TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" style = 'font-size:10px' COLOR="#0B333C" LETTERSPACING="0" KERNING="0"><B></B></FONT></P></TEXTFORMAT><TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" style = 'font-size:10px' COLOR="#0B333C" LETTERSPACING="0" KERNING="0"><B> What number does this Roman numeral represents MDCCCXVIII ?</B></FONT></P></TEXTFORMAT></b>
    </body>
    </html>
    But by using the above regular expression i am getting like this.
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head><body>
    <b><TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" style = 'font-size:10px' COLOR="#0B333C" LETTERSPACING="0" KERNING="0"><B></B></FONT></P></TEXTFORMAT><TEXTFORMAT LEADIN G="2"><P ALIGN="LEFT"><FONT FACE="Verdana" style = 'font-size:10px' COLOR="#0B33 3C" LETTERSPACING="0" KERNING="0"><B> What number does this represents</B></FONT></P></TEXTFORMAT></b>
    </body>
    </html>
    Here what happening means it was replacing space with &nbsb; in HTML tags also.But want to replace space with &nbsb; present in the outside of the HTML tags.I want like this using regular expressions in FLEX
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>What&nbsb;number&nbsb;does&nbsb;this&nbsb;represents</body>
    </html>
    Hi,Please give me the solution to slove the above problem using regular expressions
    Thanks in Advance to all
    Regards
    ssssssss

  • Getting "Inner Html" using Regular Expressions. Learning RE in SDK1.4.

    Hello group.
    I am learning Regular Expressions in JAVA SDK 1.4 first. Not PERL or other language.
    Using the utility at the following link I am trying to get all the text between the <TR> and </TR> tags.
    http://jakarta.apache.org/oro/demo.html
    This seems simple but the line returns, breaks etc.. make it more difficult. I have worked on this for hours.
    There will be multiple table rows in my stream.
    My goal is to first get the text between the <TR> Tags...
    Then I was going to use groups to get data0, data1, data2, data3.
    Does this sound like a good plan? Should I use multiple RE or one RE that does 4 group returns.
    I was thinking the applet was causing my problem.
    <TR>.*?</TR> does not work.
    (<tr>\s*([^(</tr>)])+</tr>) does not work.
    I can get data0 to work as well as data1,2,3.
    Would it make more sense to split this multiple row table by </tr>?
    One row of malformed html (actually multiple rows):
    <TR>
    <TD bgColor=#ffffff><A class=fav
    href="http://nicesite.com/data0"
    >nicesite</A><IMG
    src="smile.gif"></TD>
    <TD bgColor=#12ff22><SPAN class=fav>data1</SPAN></TD>
    <TD bgColor=#12ff22><SPAN class=fav>data2</SPAN></TD>
    <TD bgColor=#12ff22><SPAN class=fav>data3</SPAN></TD>
    <TD align=middle bgColor=#ffffff><A
    href="#"><IMG
    src="smile.gif" border=0></A></TD>
    <TD align=middle bgColor=#ffffff>data
              4</TD>
    <TD align=middle bgColor=#ffffff>data5</TD></TR>
    s_____ I have seen some of your post and tryed to apply them. What do you think?
    Regards,
    NupeVic

    http://jakarta.apache.org/oro/demo.htmlI prefer
    http://jregex.sourceforge.net/demoapp.html
    >
    This seems simple but the line returns, breaks etc..
    make it more difficult. Yes, they do indeed
    There will be multiple table rows in my stream.
    My goal is to first get the text between the <TR>
    Tags...
    Then I was going to use groups to get data0, data1,
    data2, data3.
    Does this sound like a good plan? Should I use
    multiple RE or one RE that does 4 group returns.One of the main features of regexes that you must realize
    is that they are mainly suited for non-recursive, linear data structures
    (btw, that's why regexes in general are hardly suited for html).
    So, if the number of TD items is fixed, you could
    1. search using a single pattern for the whole row, something like
    "<PatternForTR>"+
    "<PatternForTD>(<PatternForData>)<PatternFor/TD>"+
    "<PatternForTD>(<PatternForData>)<PatternFor/TD>"+
    "<PatternFor/TR>"
    so the group1 would contain data1 and so on
    Otherwise, you should
    2. find each row using
    "<PatternForTR>(.*?)<PatternFor/TR>",
    then search the contents of group1 using the
    "<PatternForTD>(<PatternForData>)<PatternFor/TD>".
    >
    <TR>.*?</TR> does not work.The pattern itself is ok, but in order for it to work one should enable the DOTALL flag (the 's' flag in jregex demo), as the '.' doesn't accept line breaks by default.
    (<tr>\s*([^(</tr>)])+</tr>) does not work.It seems that [^(</tr>)]+ actually is a nonsense in this context.
    It describes a string that consists of any chars but '(', ')', '<', '>', 'r', 't', '/'.
    What you actully meant (a string that doesn't contain "</tr>")
    is just achieved by using non-greedy quantifier in <TR>.*?</TR>.
    >
    I can get data0 to work as well as data1,2,3.
    Would it make more sense to split this multiple row
    table by </tr>?Going the second way above, you could find rows using the
    general pattern for TR:
    <tr.*?>(.+?)</tr> and search their contents(i.e. the group#1) using the
    general pattern for TD
    <td.*?>(.+?)</td> Finally, this is the specific pattern for TD that doesn't include the leading
    and trailing tags into group1:
    <td[^>]*>(?:\s*</?[^>]*>)*\s*(.+?)(?:\s*</?[^>]*>)*\s*</td>It succeded in finding
    nicesite
    data1
    data2
    data3
    data
    4
    data5in your sample.

  • Stripping HTML thru regular expression(pls help)

    Hi all..
    I've been trying to use the regular OROMatcher-1.1 expression package downloaded from apache.org.
    it works well with my program but i m having problems building correct regular expression to strip off HTML tags.
    can any of u help me build an expression tha strips of ALL html tags including those with funny spaces such as:
    <a href = "www.here.com">click me</a>
    do help pls. i've tried for ages and its driving me mad

    Hi,
    Wont go into much details but the simplest way to do that would be using XML technology. Try using SAX or DOX whatever you feel comfortable with. I think SAX would be a better choice. For details visit
    http://java.sun.com/xml/?frontpage-spotlight
    /khurram

  • Regular Expression Escaped Digit "\d" Illegal Escape Character

    Hello,
    I'm trying to write a regular expression to determine if a String matches a date format that is defined as YYYYMMDD. For example, March 11, 2009 would be "20090311"
    For the time being I don't care if an invalid month or day is entered. I've attempted both of the following
    if (date.matches("(19|20)\d{4}")) {
      // warn the user
    }and
    if (java.util.regex.Pattern.matches("(19|20)\d{4}"), date)) {
      // warn the user
    }And both yield Illegal Escape Character compilation errors, for the "\d" part of the regular expression.
    http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html#sum
    Says that "\d" is the predefined digit character class. So at this point, I don't know what I'm doing wrong. I realize I could just define the character class myself, and use a pattern like "(19|20)[0-9]{4}", but I would like to know why "\d" isn't being recognized by the compiler.
    Thanks,
    Paul

    paulwooten wrote:
    Can someone give me an explanation of heuristics, as they might apply to SimpleDateFormat? Does this mean that if the format was similar the parser might figure it out? Say, if instead of "yyyyMMdd", it was "yyyyddMM", or "yyMMdd"?No. Since all of these are valid formats, there's no way for the parser to distinguish this.
    Or does this have to do with rejecting February 29, and other dates like that.That's the one. When setLenient(false) is called, then the 29th February is only accepted in leap years.
    It will also reject the 57th January when lenient is set to false (try parsing that with lenient=true, you'll be surprised).
    I've read some of the wikipedia article about heuristics, but I'm confused as to how it would apply to this example.Don't concentrate to much on the term heuristics. Just remember: lenient=true means that not-really-correct dates will be accepted, lenient=false means more strict checks.

  • Regular Expression to remove space in HTML Tag

    Hello All,
    My HTML string is like below.
    select '<CityName>RICHMOND</CityName> 
    <StateCd>ABCD CDE 
    <StateCd/>
    <CtryCd>CAN</CtryCd>
    <CtrySubDivCd>BC</CtrySubDivCd>' Str from dual
    Desired Output is
    <CityName>RICHMOND</CityName><StateCd>ABCD CDE 
    <StateCd/><CtryCd>CAN</CtryCd><CtrySubDivCd>BC</CtrySubDivCd>
    i.e. want to remove those spaces from tag value area having only spaces otherwise leave as it is. Please help to implement the same using Regular expression.

    Hi,
    It's unclear what you want.  This site seems to be formatting your message in some odd way.
    Post a statement like
    SELECT '...' FROM dual;
    without any formatting, to show your input, and post the exact output you want friom that, with as little formatting as possible.  It might help if you use some character like ~ instead of spaces (just for posting; we'll find a solution that works for spaces).
    To remove the text that consists of spaces and nothing else between the tags, you can say
    REGEXP_REPLACE ( str
                   , '> +<'
                   , '><'
    How is this string being generated?  Maybe there's some easier, more efficient way to keep the bad sub-wrtings out of the string in the first place.

  • Regular Expressions for converting HTML to Structured Plain Text

    I'm writing a PL/SQL function that will convert HTML to plain text, but still preserve some of the formatting/line breaks. One of my challenges is in writing a regular expression to capture the text blocks while ignoring the markup. I'm trying to write an expression that will grab all of the text between start/end tags, but discard the tags. For example, to find all of the text between a start/end paragraph, I want to do something like:
    REGEXP_REPLACE('&lt;p style=&quot;text-align:center&#59;&quot;&gt;This is the body of the paragraph&lt;/p&gt;', '&lt;p.*&gt;(.*)&lt;/p&gt;', '\1||v_crlf' )
    where \1 returns the contents of the paragraph and v_crlf (declared earlier in the function) inserts a line break. I know there are more general expressions that will remove all tags, but I want to specifically identify the tags so I can process them appropriately. This way I can easily convert HTML to plain text for email and reporting without having to keep two versions around. Any help would be greatly appreciated. Once I get this worked out, I will repost with the function code for others to use. Thanks.
    Edited by: jritschel on Oct 26, 2010 9:58 AM

    Here's a function I wrote for an app. I'm not making in promises on it's accuracy as the app was just a proof of concept and never made it to production.
    function strip_html( p_clob in clob )
    return clob
    is
        l_out clob;
        l_test  number := 0;
        l_max_loops constant number := 20;
        i   pls_integer := 0;
    begin
        l_out := regexp_replace(p_clob,'<br>|<br />',chr(13)||chr(10),1,0,'imn');
        l_out := regexp_replace(l_out,'<p>',chr(13)||chr(10),1,0,'imn');
        l_out := replace(l_out,'<li>',chr(13)||chr(10)||'*<li>');
        l_out := regexp_replace(l_out,'<b>(.+?)</b>','*\1*',1,0,'imn');
        l_out := regexp_replace(l_out,'<u>(.+?)</u>','_\1_',1,0,'imn');
        loop
            l_test := regexp_instr(l_out,'<([A-Z][A-Z0-9]*)[^>]*>.*?</\1>',1,1,0,'imn');
            exit when l_test = 0 or i > l_max_loops;
            l_out := regexp_replace(l_out,'<([A-Z][A-Z0-9]*)[^>]*>(.*?)</\1>','\2',1,0,'imn');
            i := i + 1;
        end loop;
        return l_out;
    end strip_html;{code}
    The loop is there to handle nested HTML.
    Tyler Muth
    http://tylermuth.wordpress.com
    "Applied Oracle Security: Developing Secure Database and Middleware Environments": http://sn.im/aos.book
    Edited by: Tyler on Oct 26, 2010 10:03 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • [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.

  • Splitting html ul tags and their content into string arrays using regular expression

    <ul data-role="listview" data-filter="true" data-inset="true">
    <li data-role="list-divider"></li><li><a href="#"><h3>
    my title
    </h3><p><strong></strong></p></a></li>
    </ul>
    <ul data-role="listview" data-filter="true" data-inset="true">
    <li data-role="list-divider"></li><li>test.</li>
    </ul>
    I need to be able to slip this html into two arrays hold the entire <ul></ul> tag. Please help.
    Thanks.

    Hi friend.
    This forum is to discuss problems of C# development. Your question is not related to the topic of this forum.
    You'll need to post it in the dedicated Archived Forums N-R  > Regular Expressions
     for better support. Thanks for understanding.
    Best Regards,
    Kristin

  • Regular expression - escape characters

    Hi. Is there an escape character for "?", "[", "]", "{", "}" for regular expression? I tried to do the following: "[^[]?{}]*" (the string cannot contain a question mark, left or right bracket, or left or right curly brace). However, I get an error stating unexpected character.
    thanks,
    Paul.

    Hi. Is there an escape character for "?", "[", "]",
    "{", "}" for regular expression? I tried to do the
    following: "[^[]?{}]*" (the string cannot contain a
    question mark, left or right bracket, or left or right
    curly brace). However, I get an error stating
    unexpected character.
    You should only have to escape the characters that cause a problem in the character class, rather than everything so the following should work.
    "[^\\[\\]?{}]*"

  • Java Regular Expression to grab html tags

    Dear all,
    I have written a regular expression in java to grab the pairs of html tags in a String. It worked fine except that it cannot handle space or new line. What have I done wrong?
    My regular expression (I would use <tr></tr> as an example):
    <tr[^>]*>(.*?)</tr>
    It would work for <tr><one>two<three></tr>
    but not <tr ><one>two<three></tr>
    or <tr> <one> two <three></tr>
    or <tr>
    <one>two<three>
    </tr>
    Thanks a lot in advance

    I have written a regular expression in java to grab the pairs of html tags in a String. I'll make one last-ditch suggestion that you grab a decent HTML parser, as the HTML specification allows for HTML tags that don't come in pairs. While I'm sure you will be able to eventually write regexes to handle this, it may be easier (depending on your requirements) to use tools to parse the HTML.
    Good luck!

  • Regular expression for BBcode list to html list

    Hi,
    we are migrating BBforum to Jive forum.
    BBforums has data which contains BBcode Strings.i found the follwoing code after googled.
    public static String bbcode(String text) {
    String html = text;
    Map<String, String> bbMap = new HashMap<String, String>();
    bbMap.put("(\r\n|\r|\n|\n\r)", "<br/>");
    bbMap.put("\\[b\\](.+?)\\[b\\]", "<strong>$1</strong>");
    for (Map.Entry entry : bbMap.entrySet()) {
    html =
    html.replaceAll(entry.getKey().toString(), entry.getValue().toString());
    return html;
    i have BBcode with format like
    [list] [*]blue[*]red[*] green[list]
    i have to replace this by <ul><li>blue</li><li>red</li>
    Can any one sugeest me java regular expression which replace as above
    Edited by: 875452 on Jul 31, 2011 8:03 AM

    Moderator advice: Please read the announcement(s) at the top of the forum listings and the FAQ linked from every page. They are there for a purpose.
    Then edit your post and format the code correctly.
    Moderator action: Moved from Development Tools » General Questions
    db

  • Regular expression for html links

    Hi, I'm trying to get text/link pairs from a string, accepted links
    are like:
    text1
    text2
    The expected result would be:
    url: url1
    Text: text1
    url: url2
    Text: text2
    I use the following regular expression to catch the texts and the urls:
    "<a href=\"*(.*)\"*.*>(.*)</a>"
    group(1) should be the url and group(2) the text.
    But it doesn't work ok, I got something like:
    url: http://url1/" garbagetags
    text: text1
    url: utl2
    text: text2
    I'm trying to avoid links with " and without it and dinamic html
    tags.
    I think the problem is the Regular Expression string, I'm new using
    them and I can't found the right one, if you know what's wrong with
    my R.E. string, please help me.!
    thanx

    Had to break it in to two regular expressions:
    import java.util.regex.*;
    class B2  {
       public static void main(String[] args) {
            //String INPUT = "<a href=\"http://url1/\" garbagetags>text1</a>";
            //String INPUT = "<a href=url2>text2</a>";
            //String INPUT ="<a href=\"http://www.google.com\">Google search engine</a>";
              String INPUT="<a id=1a class=q href=\"/imghp?hl=en&tab=wi&ie=UTF-8&oe=UTF-8\" onClick=\"return c('www.google.com/imghp','wi',event);\"><font size=-1>Images</font></a>";
            //String REGEX = "<a .*href=\\\"?h?t?t?p?:?/?/?([\\w\\.\\?\\&=\\-\\d]*)/?\\\"?.*>(.*)</a>";
            String REGEX = "<a .*href=\\\"?h?t?t?p?:?/?/?([\\w\\.\\?\\&=\\-\\d]*)/?\\\"?.*>";
            String REGEX2 = ">\\b([\\w\\s\\d]+)\\b<";
            Pattern p = Pattern.compile(REGEX);
            Matcher m = p.matcher(INPUT);
            StringBuffer sb = new StringBuffer();
            if ( m.find() ) {
            System.out.println(m.group(1) + "     " );  }
            else { System.out.println("No MAtch found");  }
            Pattern p2 = Pattern.compile(REGEX2);
            Matcher m2 = p2.matcher(INPUT);
            if ( m2.find() ) {
            System.out.println(m2.group(1) + "     " );  }
            else { System.out.println("No MAtch found");  }
    } You do realize that you'll never get 100% accuracy with this. There are too many possible variations to account for them all.

  • Regular expression substitution with escaped $

    I'm looking to perform a substitution (along the lines of String.replaceAll()) that matches with the character $. I have tried $, \$, \\$, and variations thereof in the regex string utilizing String.replaceAll() and with a Pattern.compile(). In both cases I get an "Illegal repetition near index X" error. Anyone have suggestions as to escaping the $ character for regular expression substitutions?
    Edited by: dolcraith57 on Dec 6, 2007 11:18 AM

    It would help if you'd post details--e.g. original string and desired result, with an explanation of the rules.
    str1 = "a$1$2$b$";
    str2 = str1.replaceAll("\\$", "X"); // aX1X2XbX
    str3 = str1.replaceAll("\\d", "\\$"); // a$$$$$b$

  • Regular Expression escaping problem!

    Hi all,
    Well as you know characters such as '*' and '?' are reserved characters in regular expression so I suppose if I want to find the exact character (a '?' for example) in a string, I have to escape it with a backslash:
    str=str.replaceAll("\?","a");
    In the statement above, I need to replace all question marks with another character but it has a compile error:
    Error(116,48): invalid escape character
    to my surprise this following code does the job while it should be interpreted as: one occurance of the '\' character or nothing at all:
    str=str.replaceAll("\\?","a");
    What's the problem? what's the general rule on escaping such characters?

    I think you're right.
    The point is that java first interprets the String and handle its own scape characters then the result would be passed on to reqular expression parser.
    so I guess in order to search for one occurance of the '\' character or nothing at all the java string would be:
    so that the input to reqular expression parser would be:
    while in the first situation:
    a "\\?" java string is first trasformed into \? which will be considerd as one occurance '?' in reqular expression point of view...
    Message was edited by:
    nerssi
    Message was edited by:
    nerssi

Maybe you are looking for

  • Error while running adlnkoh.sh. Please check logfile

    Hi All, i got this error while cloning i ran perl adcfgclone.pl dbTechStack on db tier Starting ORACLE_HOME relinking... Instantiating adlnkoh.sh Starting relink of ORACLE_HOME - RDBMS Adding execute permission to : /erpapp/prod/proddb/10.2.0/appsuti

  • How to handle Changes in the Structure of Outbound Message.

    Hi Experts, I have a File2RFC scenario where the Outbound Message fields are (for e.g,) ID,Name,Loc, and Status. The structure of the xml file which needs to be picked by sender file adapter is changing each time based on the data entered by the user

  • Enq: TX - row lock contention in AWR reports

    Dears, One of my friends asked me to give him a help on analyzing a performance problem they are experimenting from time to time. First of all I am sorry to tell you that he didn’t gave me a lot of information. I will share with you all what I have b

  • Trigger IDoc DELVRY03 after Inbound Delivery create

    Hi, Inbound delivery is created through an Inbound IDoc and I want to trigger an outbound DELVRY03 IDoc when the Inbound Delivery is created. How do I trigger this? Regards, Sneha

  • WebLogic Cluster License Question

    We are currently testing WebLogic 5.1 clustering in our dev environment. I have 4 instances of the clusters running on the same machine but under different IP addresses. I have separate license files under individual license directories under each se