A reg expression bug?

would this be a regexp bug?
Pattern patter=Pattern.compile("SYSTEM_ROOT");
           Matcher m=patter.matcher("SYSTEM_ROOT/hello.gif");
           if(m.lookingAt()){
                    System.err.println(m.replaceAll("c://"));
          }An exception is thrown
java.lang.StringIndexOutOfBoundsException: String index out of range: 3
     at java.lang.String.charAt(String.java:444)
     at java.util.regex.Matcher.appendReplacement(Matcher.java:551)
     at java.util.regex.Matcher.replaceAll(Matcher.java:661)
     at com.titan.software.tbm.io.FileUtil.main(FileUtil.java:161)     

Yes! sorry I used m.replaceAll("c:\\")
I just read the issue with \\ in the bug database.
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5024613
It seems like backslash it not interpreted literally in m..replaceAll("\\\\") so I have to use m.replaceAll("C:\\\\") to achieve what I really want. javac will convert c:\\\\ into c:\\ , then replaceAll will convert c:\\ into c:\
is this right?
thanks
Are you sure you don't have this:m.replaceAll("c:\\") // with backslashesin
your code? That would cause that exception.

Similar Messages

  • Validate through Reg Expression

    Hi,
    I have following requirement to be achieved through reg expressions.
    Need to write a boolean method which takes a String parameter that should satisfy following conditions.
    o 20 character length string.
    o First 9 characters will be a number
    o Next 2 characters will be alphabets
    o Next 2 characters will be a number.(1 to 31 or 99)
    o Next 1 character will be an alphabet
    o Last 6 characters will be a number.
    JDev 11.1.1.6.0

    Hi,
    Hope following links are useful
    https://blogs.oracle.com/shay/entry/regular_expression_validation
    http://www.vogella.com/articles/JavaRegularExpressions/article.html

  • CFINPUT Reg Expression Validation Pattern Help

    I've got a form with a non-required field that needs to meet
    some validation requirements (Numbers, Letters, 'space character'
    or 'blank, empty string' only) if the user chooses to fill it
    out...
    I'm using CFINPUT tag with the following settings, does my
    Reg Expression pattern look OK?
    REQUIRED="No"
    VALIDATE="regular_expression"
    PATTERN="^[a-zA-Z *]{1,40}$"
    MAXLENGTH="40"
    Thanks for any help. I'm v. new to regular expressions (10
    hrs education at Google Univ.)
    Sincerely,
    Paul Cross

    I think you want something more like this:
    ^[a-zA-Z0-9 ]{0,40}$

  • Reg expression help

    Can/will you help me make a regular expression for these characters? I want to replace eveyone occurance in a string contianing these chars
    \/:*"<>|
    with
    right now I am doing a string.replaceAll(...) on each char but I was wanting to combine that to one reg expression. What cha got? I am doing this b/c I am generating file names and those are not valid chars allowed in file names.
    Thanks
    Doopterus

      String regex = "[*<>/'\"\\\\]";In a character class (i.e., between the square brackets), "|" has no special meaning.

  • The "Not" expression bug of Oracle BPM Studio 10.3.0.0.0

    I'm new user of BPM. And I took part in the training cause in Oct 9th-10th in Guangzhou Oracle. I found a potential bug when I practise the tutorial in Oracle BPM(BEA) Studio 10.3.0.0.0.
    Because the Comfirm Report activity in the tutorial can't go next when the treasurer role check all the items in the expense report.
    In the tutorial provided by Oracle BPM Studio.
    the "not" expression can't be evaluated. e.g.
    {color:#333399}<strong>if not item.receiptChecked then ...</strong>{color}
    But I use ==false clause, it works correctly:
    {color:#333399}<strong>if item.receiptChecked == false then ....</strong>{color}
    The code is from {color:#808000}"Oracle BPM Basic Tutorial &gt; Activity 4: Adding Alternative Paths &gt; Adding the Not Confirmed Transition"{color}
    {color:#333399}<strong>for each item in items do</strong>
    <strong>if not item.receiptChecked then</strong>
    <strong>return false</strong>
    <strong>end</strong>
    <strong>end</strong>{color}
    Edited by: user10474563 on 2008-10-26 上午8:59

    We just finsihed a BPM 6.0.4 project that integrates with IBM Websphere MQ 6.0.
    There are many, many steps that are needed to be done in order to integrate but it works very well.
    If you email me at [email protected] I will send you what I have.

  • Aftereffects expression BUG. cannot compare the values of 2 sliders???????

    so do this:
    make a new comp with a new solid.
    add 2 slider effects to the layer.
    add an expression to the Opacity of the solid, add this tot he expression:
    // begin expression
    if(effect("slider_01")("Slider") == effect("slider_02")("Slider")){
    100
    }else{
    0
    // end expression
    then try setting the values of the sliders to be exactly the same. IF they are exactly the same, the solid should be visible.
    they NEVER evaluate as true. Which means this is a bug, no?

    hah!
    why is it like this?
    to compare the values of sliders, you can't just pick whip to it, like you are able to do for almost everything else.
    the trick is to pickwhip, get this: effect("slider_01")("Slider")
    then add    .value      to the end of it. because consistency is key.

  • LoopOut expression - bug - please confirm

    Can somebody try this and confirm I'm not crazy.
    ******BUG******
    LoopOut and LoopIn do not cycle properly with Position property.
    Steps to reproduce bug:
    1. Create a composition at 960x540
    2. Create a solid that is 50x50
    3. On frame 0, keyframe the position of the solid at 540,500.
    4. Copy that keyframe to Frame 1
    5. On frame 5, keyframe the solid's position to 540,100.
    6. Copy that keyframe to frame 6.
    7. Add an expression to the Position property: loopOut ("cycle",0)
    Results:  If you watch the position values as you step the frames, you will see the pattern keeps changing and is not a consistent cycle. Sometimes the 500 value is repeated, and sometimes the 100 value is repeated.  It is inconsistent.
    Expected results: The position values should change following a fixed pattern and not vary after the final keyframe.

    Thanks for following up, but I do believe it's a bug.  Follow along closely -- because I know it gets confusing...
    (BTW, I'm now using CC on a PC).
    If you use my original scenario.
    Then the Y value for frames 0 through 6 are: 500, 500, 400, 300, 200, 100, 100 -- then the loop begins since the second 100 is the last keyframe.
    As it continues, you would expect it to go back to the beginning and cycle through those same numbers BUT not the second 100 since that's the end of the loop and it ignores the last keyframe for purposes of cycling.
    Jump ahead to....
    Frame 12 is 500 (as expected) - the beginning of a cycle
    Frame 13 is 500 (as expected). 
    Frame 17 is 100 (as expected) - the end of the cycle
    Frame 18 is 100 (not expected) -- why is 100 doubling up now when that last keyframe should be ignored?
    Frame 19 is 500 (as expected)
    Frame 20 is 400 (not expected) - why didn't 500 double up like it did on frame 12 and 13?  It's because the 100 doubled up instead and took it's place in the cycle.
    Frame 23 is 100 (as expected)
    Frame 24 is 500 (as expected)
    Frame 25 is 500 (as expected -- now 500 is doubling up again. But it didn't on frame 20?
    This cycle continues where 500 is duplicated on one cycle and the 100 is duplicated on the next cycle... meaning there is a cycle but it's twice the length of the original keyframes.  It is cycling over 12 frames instead of 6.
    Now here is why I definitely think what I'm seeing is a bug -- move the latter two keyframes from frames 5,6 to 7,8.
    As soon as you do this the doubling of the 100 keyframe stops occurring in the pattern and it behaves as expected.  The issue seems to be related to short duration loops. 

  • Reg expression

    can somebody tell me how to write a query using regular expression instr function to find any alpha character in a string except + - .
    i have a varchar field that can contain any of the following values
    234, 345.32, -66.33, +32.
    if the value enter is 34a or +455.44v then i want to search for alpha character except the . and + sign. so i will searching for v or a.

    Something like this?
    WITH t AS (SELECT '234' col1
                FROM dual
               UNION
              SELECT '345.32'
                FROM dual
               UNION
              SELECT '-66.33'
                FROM dual
               UNION
              SELECT '+32.'
                FROM dual
               UNION
              SELECT '34a'
                FROM dual
               UNION
              SELECT '+455.44v'
                FROM dual
    SELECT t.col1
         , REGEXP_REPLACE(t.col1, '^[+-]|\.[0-9]+|[0-9]+(\.[0-9]*)?', '')
      FROM t
    WHERE NOT REGEXP_LIKE(t.col1, '^[+-]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)$') 
    ;                       C.

  • Seemingly simple, yet annoying reg. expression issue

    Hey guys,
    Im considerably familiar with the use of regular expressions in Java (and other languages), yet seem to be having a very simple problem.
    I wish to match a full stop character occuring after a space in a string, once that space does not occur after a digit.
    e.g. "went to the shop . This is another sentence"
    The code I'm using is this:
    String s = "went to the shop. This is another sentence"
    s = s.replaceAll("([^0-9]+)\\s+\\.","$1.");This doesn't seem to work, neither does:
    String s = "went to the shop. This is another sentence"
    s = s.replaceAll("(\\D+)\\s+\\.","$1.");It seems that there's a problem with the first + symbol, but I'm not sure exactly what the problem is.
    Any insights?
    Edited by: SuperGrover on Jan 19, 2009 12:35 PM

    SuperGrover wrote:
    The problem seems to occur when there's more than one occurance of the space before a fullstop in the string, so the above code doesn't work for the following string:
    "went to the shop . This is another sentence . And another"
    It only replaces the final occurance, despite using the replaceAll method.When I tested your pattern (using JRET), it matched both occurrences in the sample string!
    The matching was done by repeated invocations of the method [Matcher.find|http://java.sun.com/javase/6/docs/api/java/util/regex/Matcher.html#find()].
    Maybe [String.replaceAll|http://java.sun.com/javase/6/docs/api/java/lang/String.html#replaceAll(java.lang.String, java.lang.String)] does something different internally?
    Anyway, are you aware that your expression always matches the entire string preceding the space and the dot?
    This is probably not really what you are looking for. You may want to try this expression instead, which uses negative lookbehind:
    (?<!\d)\s+\.Edited by: McNepp on 20.01.2009 09:47

  • Reg Expression in af:validateRegEx

    Since I can't use my custom validator class (See post Custom validator closes dialog on failure I am trying to use the same regular expression in an <af:validateRegExp> on an <af:inputText>.
    I have tested my regular expression in a completely separate tester that I wrote and it works for every test case I throw at it.
    I put the regular expression inside my custom validator class and it works as expected as well, but I can't use it for above posted reasons.
    So now I've put the regular expression in my backing bean as a private attribute and created a getter method for it. In the validationRegExp component, I used an EL expression to point to the attribute in my backing bean. When I run and put in the same test values, they fail validation.
    The documenation for the validateRegExp says it uses java regular expression syntax, so I shouldn't have to change the regex between the custom validator and the validator component.
    Any ideas?
    Al

    What doesn't work:
    Every success test value that I put in the input text box fails validation. Or maybe I should say that every value I put in the input text box fails validation, although one would expect the failure test value to fail validation, so obviously the issue is that a valid success test value fails validation using the <af:validateRegEx> component with the same regex used in the custom validation class where the same input passes validation.
    What is the issue I see:
    That success test values fail validation using the <af:validateRegEx> component.
    Implentation:
    <af:popup id="resetPasswordPopup"
              binding="#{pageFlowScope.backing_Bean.resetPasswordPopup}">
    <af:dialog id="resetPasswordDialog" type="none"
               title="Reset Password">
    <af:panelGroupLayout layout="vertical">
    <af:outputText value="Enter temporary password for user:"/>
    <af:spacer width="10" height="10"/>
    <af:inputText label="Temporary Password"
                  value="#{pageFlowScope.backing_Bean.temporaryPassword}"
                  required="true">
    <af:validateRegExp pattern="#{pageFlowScope.backing_Bean.passwordRegEx}"
                       hint="Password should be ...."/>
    <!--<f:validator validatorId="passwordValidator"/>-->
    </af:inputText>
    </af:panelGroupLayout>
    <f:facet name="buttonBar">
    <af:panelGroupLayout layout="horizontal" halign="center">
    <af:commandButton text="Yes"
                      action="resetUserPassword"
                      partialSubmit="true"/>
    <af:spacer width="10" height="10"/>
    <af:commandButton text="No" immediate="true">
    <af:returnActionListener/>
    </af:commandButton>
    </af:panelGroupLayout>
    </f:facet>
    </af:dialog>
    </af:popup>

  • Email Reg Expression

    dear all :
    i am using ADF 10 with WLS 11
    i am using the following regular expression for email account :
    <af:validateRegExp pattern="^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$" id="nr3hj" messageDetailNoMatch="#{viewBundle.PleaseInsertValidEmail}"/> and it work fine .
    but i need to force the end user to add the email as the following
    [email protected]
    her i can add ABC@yahoo without (.) dot ,
    so how i can force the end user to add (.) dot in his email like .com , .net , .etc .
    Best Regards

    bara,
    Try [url http://tinyurl.com/lfugwr]this link
    John

  • Help with Reg Expression Start method

    Hi there,
    I've been looking through some examples of regular expressions and I've became totally unglued at what the start method of the Matcher class returns.
    Here's the example...
    Passing in "\d*" ab34ef to the following code
    import java.util.regex.*;
    public class Class1
      public static void main(String []args)
        Pattern p= Pattern.compile(args[0]);
        Matcher m=p.matcher(args[1]);
        boolean b=false;
        while (b=m.find())
          int x=m.start();
          String y=m.group();
          System.out.print(x + y);
    }Gives the output
    01234456
    I understand eveything apart from the 6 character. How can m.start()return 0 (at the start) and 6 at the end when the string being searched is 6 characters long.
    My head hurts.

    The fact that a string is an array of characters under the hood is just an implementation detail, and it's getting in your way. What start() returns is the beginning position of a substring which may have a length of zero.
    The first time through the loop, the regex matches a zero-length substring at the beginning of the target string. That's the position preceding the first character, index 0. Then, because the match didn't consume any characters, the Matcher moves ahead one position before trying again. Another zero-length match, another bump-along, and now it's at index 2. This time, the regex can actually match some characters. It matches the substring "34", and that brings us to the part that's really confusing. Because the previous match consumed some characters, the Matcher doesn't do a bump-along before attempting the next match. It matches a zero-length substring at index 4, right where the previous match ended. Then it bumps along to index five and does another zero-length match.
    Now, you and I know that the character at index 5 is the last one in a string whose length is 6, so there's no reason to look for any more matches at this point. And if the regex were required to match at least one character, the Matcher wouldn't bother trying again. But in this case a zero-length match is considered valid, and there's one more position where that's possible. It does one last bump-along and matches nothing once more.

  • Java reg expressions

    Does anyone know of a regular expression that will parse all of the text not inside tags of an html document and write it out? Even if the html is badly coded with tags that open and do not close on the same line. I am trying to use backreferencing. Here is my code:
    import java.io.*;
    import java.util.*;
    import java.util.regex.*;
    public class parseHTML {
    public static void main(String[] args)
    try
    BufferedReader in = new BufferedReader(new FileReader("In.txt"));
    PrintWriter out = new PrintWriter(new FileWriter("Out.txt"));
    String aLine = null;
    String pattern1 = "<.+>|.*>|<.*(.*)";
    Pattern p1 = Pattern.compile(pattern1);
    while((aLine = in.readLine()) != null)
    Matcher m1 = p1.matcher(aLine);
    if(m1.find())
    StringBuffer sb = new StringBuffer();
    m1.appendReplacement(sb, "$1" + "\n");
    System.out.print(sb.toString());
    out.print(sb.toString());
    m1.reset(aLine);
    in.close();
    out.close();
    catch(IOException exception)
    exception.printStackTrace();
    }

    Does anyone know of a regular expression that will
    parse all of the text not inside tags of an html
    document and write it out?
    No. However, I am rather certain that it is notpossible.
    ANYTHING is possible with regular expressions, its
    just doing it again on different data. Then it gets
    complicated.Nope. It is not possible write only a regular expression which will parse a "balanced" expression which goes to any depth. You can write one which goes to a fixed depth but not an arbritrary one. "Balanced" would be defined for example by opening and closing parenthesis. Or html tags.
    See "Mastering Regular Expressions" by Jeffery E.F. Fridel, Chap 4, the section on Difficulties and Impossibilities.
    Naturally you can write a program, which might even use regular expressions, to do that. But that is not the same.

  • N00b Vi Q/reg expression for html

    How do I wrap <p> </p> tags around paragraphs globally??
    And when I try to wrap <i></i> around a line, i get the error E488: trailing characters.
    :28,32s/.*/<i>&</i>/g
    . I thought this would wrap italic markers around the whole lines from 28 to 32, what am I doing wrong?
    Oh, and if anyone has a link to a good tutorial for n00bs on global substitutions by regular expressions, don't keep it to yourselves. :-)
    Last edited by Reploid (2009-03-06 18:39:35)

    Thx @ Husio. Will experiment with script a little later, trying to learn the basic stuff for now.
    Another question:
    I have sentences like:
    <p><span class=font25>4th completely revised edition</span></p>
    However, I can only seem to substitute the sentences with font0-9. (!)
    This doesn't work:
    :%s<span class=font[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,2
    5,26,27,28,29,30]\+><b>\(.*\)<\/b><\/span>/\1/
    This doesn't work:
    :%s<span class=font[0-9][0-9]*>
    This doesn't work:
    <span class=font[0-9*][0-9*]>
    What would help me get rid of the formatting markup??
    Last edited by Reploid (2009-03-08 12:54:02)

  • LMS 4.0 Compliance Reg Expression Issue

    I'm
    having problems with a regexp, I'm trying to search for multiple patterns in the loopback description field:
    Example:
    Rtr1:
    interface loopback0
    description rndm:text:cursor:1536:blah:blah1
    Rtr2:
    interface loopback0
    description rndm:text:cursor:3072:blah:blah1
    The regular expression that works is:
    +interface Loopback0
    + [#description .*:.*:.*:1536:.*#]
    But that only searches for one instance, what I cannot get to work is the following:
    +interface Loopback0
    + [#description .*:.*:.*:1536|3072:.*#]
    I have tried many variants, but I cannot get the (pipe) to work properly.
    Thanks in advance for any help,
    Craig

    Nope, still no luck, I did have to add \ in front of the
    colons to get the specific location, the asteriks wwould allow it to search for that sting any
    where in the description, but I couldn't get the pipe to work properly still, I've trie
    d moving the hard brackets, paranthesis etc.
    I ended up working around the problem, by creating individual lines:
    +[#description .*\:.*\:.*\:1536\:.*\:.*\:.*#]
    +[#description .*\:.*\:.*\:3072\:.*\:.*\:.*#]
    +[#description .*\:.*\:.*\:2048\:.*\:.*\:.*#]
    Then running the report, the report gave the output of which commands needed to be "added", so I used a seperate program to determine which devices were non-compliant, IE.
    If router one needed all 3 of those commands, then I knew it did not match any of them, and was non-compliant, if router two only needed 2 of those commands, I knew that it was compliant.
    Kind of a backwards approach, and I would still like to see the search work.
    Thanks for the help,
    Craig

Maybe you are looking for

  • Can I open files in PS 5.1 in a PS 5 installation?

    Hi. I am taking a photoshop class. The classroom pc uses PS 5 for Mac. And, I have PS 5.1. (part of Adobe Production Premium 5.5) for Windows Can PS 5 open files created in PS 5.1?

  • How to switch off internal macbook screen when using external monitor(s)

    as far as i observed, adding external displays ( running different screens on them, not mirroring)  to a macbook pro  increases the gpu workload and with that comes temperature rise in the laptop and increase in ventilator noise - and probably increa

  • "This field name is not known", Details: errorKind, Error in formula

    <p>I receive this error when running a report in our C# .NET windows form viewer hitting an oracle data source.  If I run the exact report against a MSSQL data source, it works fine.  If I run the exact report in Crystal Designer against the same ora

  • Filename is not attached with archivelink process

    Hello Experts, I installed a SAP Content Server with Max DB and I did the different customizing : - creation of  repository - creation of documents type - link of objects etc.. Today I can attach documents (CRM opportunities) without problem BUT I ha

  • [SOLVED]Doesn't openmpi work when called by fakeroot?

    I found that I can't use mpicc when I was writing a PKGBUILD. It seems that the mpicc doesn't work under fakeroot. Here is a simple PKGBUILD show how it's happened. pkgname=Testing-openmpi-on-fakeroot pkgver=1337 pkgrel=42 arch=('i686' 'x86_64') make