Unclosed character class near index 0

Hi foks,
I am tryin to remove few characters from a string with the help of replaceAll ( String, String ) method.
But at the first replacement itself it gives error "Unclosed character class near index 0".
what does this error mean? I dont have any ' [ ' character in that string. It used to be there, but now I am removing all the occuring of the ' [ ' char right at the creation of string.
Thanks in advance.

Hi,
Here is the code.
[ CODE ]
public static String extract(String para)
String definition = para.substring(para.indexOf("<ol>"),para.indexOf("</ol>"));
StringBuffer meanings=new StringBuffer();
StringReader reader = new StringReader(definition);
StringWriter writer = new StringWriter();
boolean append=false;
int ch;
try
while((ch=reader.read()) != -1)
if(ch=='<' || ch=='&')
append = false;
continue;
else if(ch=='>' || ch==';')
append = true;
continue;
if(append && ch != '[' && ch != ']')
writer.write(ch);
catch(IOException e)
System.out.println("IOException:"+e.getMessage());
catch(Exception e)
System.out.println("IOException:"+e.getMessage());
meanings=writer.getBuffer();
String temp = meanings.toString();
System.out.println("temp:"+temp);
temp=temp.replaceAll("["," ");
System.out.println("temp:"+temp);
temp=temp.replaceAll(" "," ");
System.out.println("temp:"+temp);
return temp;
[ /CODE ]

Similar Messages

  • PatternSyntaxException: Unclosed character class near index

    Hi,
    I want to replace in a string a expression like "^1:2" by "^(1/2)":
    For example, "V/Hz^1:2" would be converted to "V/Hz^(1/2)".
    I tried the following code:
    String oldExponent = "[^](\\d+):(\\d+)"; // e.g. ^1:2
    String newExponent = "^($1/$2)";         // e.g. ^(1/2)
    myString = myString.replaceAll(oldExponent, newExponent);but the following exception is thrown in the third line:
    java.util.regex.PatternSyntaxException: Unclosed character class near index 13
    [^](\d+):(\d+)
                 ^Any idea?
    Thanks in advance.

    Thank you, jverd, you are pretty right.
    Now I tried with
    "\\^(\\d+):(\\d+)"and it works.
    I tried to avoid ^ being interpreted as the beginning of the line, and didn't realize the interpretation inside the brackets.
    Escaping this character works well.

  • PatternSyntaxException: Dangling meta character '*' near index 0

    Hi,
    I am using DocumentFilter to control the input in a JtextField In accordance with model of a mask.
    The mask can contain the following characters:
        //  # :  for  =---> NUMBER only
        //  ? :  for  =---> LETTER only
        //  A :  for  =---> LETTER end for NUMBER
        //  * :  for  =---> ANYTHING    I made a class that extends DocumentFilter and it look like this:
    public class MydocumentFilter extends DocumentFilter {
    public void insertString(...){
    // do anything
        } // insertString()
    public void remove(...)
    // do anything
        } // remove()
    @Override
        public void replace(
                DocumentFilter.FilterBypass fb,
                int offset, // posizione del cursore
                int length, // Length of text to delete (solo per sostituzioni...)
                String text,// testo da inserire
                AttributeSet attrs) throws BadLocationException {
    // here are some controls that change the value of the text variable, and at last call the super class..:
            super.replace(fb, offset, length, text.replaceAll(text, replace), attrs);
        } // replace()
    } // class  MydocumentFilterI have a problem when the user write wildcards (='*' OR '?').
    Then I get the message:
    Exception in thread "AWT-EventQueue-0" java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0.I know that '*' and “?” are is a metachars and for that I added this code before calling super.replace(...);
            if (text.compareTo("*") == 0){
                replace = "\\*";
            }but I don't get the expected result. I get -\*- instead then -*-
    here the code of the program that I use to make tests:
    * http://www.java2s.com/Tutorial/Java/0260__Swing-Event/CustomDocumentFilter.htm
    * @author Owner
    //public class IntegerRangeDocumentFilter extends DocumentFilter {
    public class NavBean_documentFilter extends DocumentFilter {
        enum CharAcceptability_ENUM {
            valid, invalid, overrite
        String mask;
        public NavBean_documentFilter(String mask_) { // constructor
            mask = mask_;
        } // constructor
        @Override
        public void insertString(
                DocumentFilter.FilterBypass fb,
                int offset,
                String string,
                AttributeSet attr) throws BadLocationException {
            System.out.println("insert string" + string);
            System.out.println(offset);
            super.insertString(fb, offset, string, attr);
        } // insertString()
        @Override
        public void remove(DocumentFilter.FilterBypass fb, int offset, int length)
                throws BadLocationException {
            System.out.println("remove");
            super.remove(fb, offset, length);
        } // remove()
        public void replace(
                DocumentFilter.FilterBypass fb,
                int offset, // posizione del cursore
                int length, // Length of text to delete (solo per sostituzioni...)
                String text,// testo da inserire
                AttributeSet attrs) throws BadLocationException {
            boolean valid = true;
            if (offset > mask.length()) {
                return;
            if (text.length() != 1) {
                return;
            CharAcceptability_ENUM charAcceptability_ENUM = checkTheInput(text, offset);
            String replace = null;
            switch (charAcceptability_ENUM) {
                case invalid:
                    replace = "";
                    break;
                case valid:
                    replace = text;
                    break;
                case overrite:
                    char cc = mask.charAt(offset);
                    replace = String.valueOf(cc);
                    break;
            // It is because * is used as a metacharacter to signify one or more
            // occurences of previous character.
            // So if i write M* then it will look for files MMMMMM..... !
            // Here you are using * as the only character so the compiler
            // is looking for the character to find multiple occurences of,
            // so it throws the exception.:)
            if (text.compareTo("*") == 0){
                replace = "\\*";
            text = replace;
            super.replace(fb, offset, length, text.replaceAll(text, replace), attrs);
    //        super.replace(fb, offset, length, text, attrs);
        } // replace()
        private CharAcceptability_ENUM checkTheInput(String text, int cursorPosition) {
            if (cursorPosition >= mask.length()) {
                return CharAcceptability_ENUM.invalid;
            char mappedCharInTheMask = mask.charAt(cursorPosition); // qui erro
            char charToSet = text.charAt(0);
            System.out.println("carattere da mettere = " + charToSet + " ; carattere della maschera = " + mappedCharInTheMask);
            boolean placeHolderFree = mask.contains(String.valueOf(mappedCharInTheMask));
            if (!placeHolderFree) {
                return CharAcceptability_ENUM.invalid;
            CharAcceptability_ENUM charAcceptability_ENUM =
                    CharAcceptability_ENUM.invalid;
            char holdPlace = mask.charAt(cursorPosition);
            switch (holdPlace) {
                case '*': // 
                    charAcceptability_ENUM = CharAcceptability_ENUM.valid;
                    break;
                case '#': // only numbers
                    if ( Character.isDigit(charToSet)) {
                    charAcceptability_ENUM = CharAcceptability_ENUM.valid;
                    break;
                case '?': //only letters
                    if (Character.isLetter(charToSet)){
                        charAcceptability_ENUM = CharAcceptability_ENUM.valid;
                    break;
                case 'A': // letters and numbers
                    if (Character.isLetterOrDigit(charToSet)){
                    charAcceptability_ENUM = CharAcceptability_ENUM.valid;
                    break;
                    default:
                        charAcceptability_ENUM = CharAcceptability_ENUM.overrite;
            System.out.println("valore di charAcceptability_ENUM = " + charAcceptability_ENUM.toString());
            return charAcceptability_ENUM;
        } // checkTheInput()
    } // class UsingDocumentFilter
    class RangeSample {
        public static void main(String args[]) {
            JFrame frame = new JFrame("Range Example");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            // questo (in generale) e' quanto si deve fare per usare un filtro...
            JTextField textFieldOne = new JTextField();
            JLabel jLabMask = new JLabel();
            JPanel panel = new JPanel();
            String explanation1 = "      ---  use of wildCard: ---";
            String explanation2 = " #  :  is for  =---> only NUMBER ";
            String explanation3 = " ?  :  is for  =---> only LETTER ";
            String explanation4 = " A  :  is for  =---> LETTER end NUMBER";
            String explanation5 = " *  :  is for  =---> ANYTHING      ";
            JLabel jLabExplanat1 = new JLabel(explanation1);
            JLabel jLabExplanat2 = new JLabel(explanation2);
            JLabel jLabExplanat3 = new JLabel(explanation3);
            JLabel jLabExplanat4 = new JLabel(explanation4);
            JLabel jLabExplanat5 = new JLabel(explanation5);
            panel.setLayout(new GridLayout(5, 1));
            panel.add(jLabExplanat1);
            panel.add(jLabExplanat2);
            panel.add(jLabExplanat3);
            panel.add(jLabExplanat4);
            panel.add(jLabExplanat5);
            jLabExplanat1.setForeground(Color.green);
            jLabExplanat2.setForeground(Color.red);
            jLabExplanat3.setForeground(Color.red);
            jLabExplanat4.setForeground(Color.red);
            jLabExplanat5.setForeground(Color.red);
            jLabMask.setForeground(Color.blue);
            //AAA-##:***
            String mask = "##-A#A:#????  ***";
    //        String mask = "***";
            Document textDocOne = textFieldOne.getDocument();
            NavBean_documentFilter filterOne = new NavBean_documentFilter(mask);
            ((AbstractDocument) textDocOne).setDocumentFilter(filterOne);
            String jLabelTxt = "mask to use :  " + filterOne.mask + "   ";
            jLabMask.setText(jLabelTxt);
            frame.setLayout(new GridLayout(3, 1));
            frame.add(panel);
            frame.add(jLabMask);
            frame.add(textFieldOne);
            frame.pack();
            frame.setLocation(300, 150);
            frame.setVisible(true);
        } // main()
    } // class RangeSampleany advice shall be appreciated
    thank you
    regards
    Angelo Moreschini

    All that many lines for a regex question (where the error message already pointed to), which has nothing to do with Swing. An SSCCE looks different.
    if (text.compareTo("*") == 0){
    replace = "\\*";
    text = replace;
    super.replace(fb, offset, length, text.replaceAll(text, replace), attrs);You must keep the text, the regex and the replacement string apart:
    String text= "A", regEx= "A", rep= "B";
    //String text= "*", regEx="\\*", rep= "*";
    text= text.replaceAll(regEx, rep);
    System.out.println(text);And why don't you use a JFormattedTextField with a MaskFormatter which does all the job for you.

  • Error java: "Dangling meta character '+' near index 0 + ^"

    Hi,
    I'm receiving a runtime error, when I was trying to run search engine (only when I insert a symbol "+" plus or "\" slash) in B2B (E-selling of CRM-ISA 5.0).
    This is the text error:
    <b>
    java.util.regex.PatternSyntaxException: Dangling meta character '+' near index 0
    +
    ^
         at java.util.regex.Pattern.error(Pattern.java:1541)
         at java.util.regex.Pattern.sequence(Pattern.java:1658)
         at java.util.regex.Pattern.expr(Pattern.java:1558)
         at java.util.regex.Pattern.compile(Pattern.java:1291)
         at java.util.regex.Pattern.(Pattern.java:1047)
         at java.util.regex.Pattern.compile(Pattern.java:808)
         at com.sap.isa.catalog.uiclass.ProductsUI.getHighlightedResults(ProductsUI.java:487)
         at jsp_ProductsISA1173566617857._jspService(jsp_ProductsISA1173566617857.java:507)
         at com.sap.engine.services.servlets_jsp.server.jsp.JspBase.service(JspBase.java:112)
         at com.sap.engine.services.servlets_jsp.server.servlet.JSPServlet.service(JSPServlet.java:544)
         at com.sap.engine.services.servlets_jsp.server.servlet.JSPServlet.service(JSPServlet.java:186)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.runtime.RequestDispatcherImpl.doWork(RequestDispatcherImpl.java:321)
         at com.sap.engine.services.servlets_jsp.server.runtime.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:377)
         at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
         at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
         at com.sap.isa.core.RequestProcessor.processForwardConfig(RequestProcessor.java:267)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
         at com.sap.isa.core.RequestProcessor.process(RequestProcessor.java:391)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
         at com.sap.isa.core.ActionServlet.process(ActionServlet.java:243)
         at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.runtime.RequestDispatcherImpl.doWork(RequestDispatcherImpl.java:321)
         at com.sap.engine.services.servlets_jsp.server.runtime.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:377)
         at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
         at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
         at com.sap.isa.core.RequestProcessor.processForwardConfig(RequestProcessor.java:267)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
         at com.sap.isa.core.RequestProcessor.process(RequestProcessor.java:391)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
         at com.sap.isa.core.ActionServlet.process(ActionServlet.java:243)
         at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.runtime.RequestDispatcherImpl.doWork(RequestDispatcherImpl.java:321)
         at com.sap.engine.services.servlets_jsp.server.runtime.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:377)
         at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
         at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
         at com.sap.isa.core.RequestProcessor.processForwardConfig(RequestProcessor.java:267)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
         at com.sap.isa.core.RequestProcessor.process(RequestProcessor.java:391)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
         at com.sap.isa.core.ActionServlet.process(ActionServlet.java:243)
         at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.runtime.RequestDispatcherImpl.doWork(RequestDispatcherImpl.java:321)
         at com.sap.engine.services.servlets_jsp.server.runtime.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:377)
         at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
         at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
         at com.sap.isa.core.RequestProcessor.processForwardConfig(RequestProcessor.java:267)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
         at com.sap.isa.core.RequestProcessor.process(RequestProcessor.java:391)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
         at com.sap.isa.core.ActionServlet.process(ActionServlet.java:243)
         at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.runtime.RequestDispatcherImpl.doWork(RequestDispatcherImpl.java:321)
         at com.sap.engine.services.servlets_jsp.server.runtime.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:377)
         at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
         at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
         at com.sap.isa.core.RequestProcessor.processForwardConfig(RequestProcessor.java:267)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
         at com.sap.isa.core.RequestProcessor.process(RequestProcessor.java:391)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
         at com.sap.isa.core.ActionServlet.process(ActionServlet.java:243)
         at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.runtime.RequestDispatcherImpl.doWork(RequestDispatcherImpl.java:321)
         at com.sap.engine.services.servlets_jsp.server.runtime.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:377)
         at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
         at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
         at com.sap.isa.core.RequestProcessor.processForwardConfig(RequestProcessor.java:267)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
         at com.sap.isa.core.RequestProcessor.process(RequestProcessor.java:391)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
         at com.sap.isa.core.ActionServlet.process(ActionServlet.java:243)
         at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.runtime.FilterChainImpl.runServlet(FilterChainImpl.java:117)
         at com.sap.engine.services.servlets_jsp.server.runtime.FilterChainImpl.doFilter(FilterChainImpl.java:62)
         at com.tealeaf.capture.LiteFilter.doFilter(Unknown Source)
         at com.sap.isa.isacore.TealeafFilter.doFilter(TealeafFilter.java:61)
         at com.sap.engine.services.servlets_jsp.server.runtime.FilterChainImpl.doFilter(FilterChainImpl.java:58)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:373)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)</b>
    Any help will be appreciated.
    Regards
    Mark

    split() takes a regular expression, not just simple text. The + symbol means something special. Try something like split("\\+TO\\+")

  • Unexpected internal error near index 1

    Hi,
    I am convering al l occurance of "\" into "/" in a string.
    private String format(){
            input="java\\software\\";
            System.out.println("Before formating, input:" + input);
            try{           
                input=input.replaceAll("\\", "/");
                System.out.println("After formating, Input:" + input);
            }catch(Exception e){
                System.out.println("Error in formatting:" + e.getMessage());
            return input;
        }And I am getting this Error:
    Unexpected internal error near index 1
    Any idea whats wrong with above code?

    If you want to replace two backslashes with asingle
    forward slash, then you need to specify the former
    (as a regular expression) as "\\\\"OH! Thanks. I got another way and its working.
    I am using
    s.replace('\\', '/'); insteadd of
    replaceAll
    Yes, that's definitely better in this case, since that API is simpler for single-char replacements. If you sometime need to replace strings though (back to the replaceAll) you'll need to be aware of how regular expressions are formed and how the backslash character plays a part in forming them.

  • 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

  • Changing from upper to lower case without character class

    hi all,desperatley need help.
    I need to create an algorithm as follows
    the implement into a program without using character class
    i have no idea how to go about this
    Create an algorithm for a program that continually reads (loops) a single character from the user and displays the ordinal (ASCII) value of the character. The program should then change the case of the character, so if it is an 'a' change to an 'A' and vise-versa and then display the new ordinal value. The program should quit when the user enters the '#' character. The program should display an error message if an invalid character is entered.
    Implement the program from question 1 into a java program. You are not allowed to use any of the methods provided in the Character class to implement your solution
    regards Paul

    How time flies...they are already assigninghomework
    for the fall term.Yeah, the nice thing about the summer is that we don't
    get as many homework problems on the forums. Oh
    well...I love how they don't even take the time to reword the hw and instead just post the prof's exact text.
    "I need help with a problem, its Ch. 9, Q 23a, can anyone help me?"

  • Regular Expressions Character Class shortcuts

    I have been learning to use regular expressions to modify some of my text files. I noticed that on my ARCH box the Character Class shortcuts do not work e.g. [[:digit:]] in an expression works but \d does not. Is this normal or is my installation broken in some way?

    Bebo wrote:
    There are several regexp "dialects". It's quite painful actually For instance, as far as I know, \d works in perl, but not in sed or grep.
    So, yes, this is normal.
    Yeah -- Henry Spencer's regexp stuff is always generally considered the portable form for sed, awk, since they're all based from it.  Newer versions of grep though do allow for a -P flag for perl-regexps to be used, but this is non-portable, obviously.
    -- Thomas Adam

  • "Incompatible line delimiter near index"

    G’day
    I’m doing a search and replace of \t\r\n, replacing it with just \r\n.  CFB says to me "Incompatible line delimiter near index", in red, down the bottom of the Find/Replace dialogue.
    What does that mean?
    Also, if I click the Help icon next to the message, I just get "The context help for this user interface element could not be found".
    Adam

    You're trying to use \n instead of \r\n in the replace.
    I got it when I matched:
    \n\t*foo
    in order to match the whitespace formatting in my source code.  The fix for me was to use
    \r\n\t*foo instead.

  • Regex character classes

    You can match ']' in a regex character class by specifying it as the first literal
    "[]]"How do you match '[' in a regex character class?
    Thanks in advance, Mel

    sabre150 wrote:
    Escape it as in
    "[\\[]"Check the Javadoc for Pattern.I swear i initially tried that... thanks sabre

  • IsDigit / digit in Character class - ouput ?

    Can somebody help me in knowing why such an output is coming while I use forDigit / digit from Character class?
    The output that I get is:
    The for Digit is
    The digit is -1
    Note : There is a blank space after the is there.
    class chard
         public static void main(String[] args)
              int a = 66;
              char ch1 = 66;
              System.out.println("The for Digit is" + Character.forDigit(a, 2));
              System.out.println("The digit is " + Character.digit(ch1, 2));
    }

    Why aren't you reading the documentation????
    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Character.html
    digit(char ch, int radix)
    "Returns the numeric value of the character ch in the specified radix.
    If the radix is not in the range MIN_RADIX <= radix <= MAX_RADIX or if the value of ch is not a valid digit in the specified radix, -1 is returned. A character is a valid digit if at least one of the following is true: "
    How do you expect value 66 which is the same as 'B' to be a valid value in base 2?
    /Kaj

  • Unclosed character literal

    I am getting the following error message, I am certain that I am putting an incorrect character in here somewhere. Any ideas?
    [javac]
    C:\tomcat\work\Standalone\localhost\hd\Report_SystemListByImplFeatures_jsp.java:53: unclosed character literal
    [javac] (features.indexOf('ov')) >= 0)?"1":"0",

    Single quotes should only be used to enclose a single unescaped character, or an escape sequence that represent a single character. If you intend to search for the substring "ov" then you must enclose ov in double quotes.

  • PR Release Strategy- transport of charact/class/ values using ALE

    Does anyone have the information relative to ALE set up for release strategy-
    I am using transactions BD91 for characteristics; BD 92 for Class and BD 93 for the actual values into release strategy.
    I need the information as to what needs to be set up in Development client and receiving clients ( Q and Prod) for these transactions i.e., RFC destinations, define ports, Identify Message types & setup partner profile configurations etc
    This will be a great help.
    Thanks
    Raj

    Hi Raj,
    Please check the below notes for more inrofmation:
      86900 -  Transport of Release strategies (OMGQ,OMGS)
      799345    Transport of release strategy disabled
      10745     Copying classification data to another client
      45951     Transporting class data: system / client. - has details of what you are looking for.
    Hope this helps.
    Regards,
    Ashwini.

  • Match string against regex or character class in Applescript

    Hello,
    In my script i get string from user and need to ensure that string contains only alphanumerical characters. There is a sample:
    #!/bin/bash
    REGEX="^[[:alnum:]]*$"
    osascript <<EOF
    tell application "SystemUIServer"
    repeat
    set username to text returned of (display dialog "Enter your name" with icon caution default answer ""  buttons{"Continue"})
    if text returned of (do shell script "if ! [[ " & quoted form of username & " =~ $REGEX ]]; then echo \"notok\"; fi") as text is equal to "notok" then
    display alert "WRONG CHARACTER"
    else
    exit repeat
    end if
    end repeat
    end tell
    EOF
    The error:
    execution error: Can▒t make text returned of "notok" into type text. (-1700)
    How can one fix this? Is it possible to do this in pure AS without invoking shell?

    Follow Tony's advice.
    Yes, you can code it entirely in AppleScript, but is a verbose beast, none the least, do to the lack of an AppleScript range operator that would permit range('A'..'z') and avoid arduous lists.
    Code:
    set goodStr to "cAt134"
    set badStr to "cAt_134"
    if not isalnum(badStr) then
      display dialog "Not ok!"
    end if
    on isalnum(username)
              set uCase to {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", ¬
                        "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", ¬
                        "U", "V", "W", "X", "Y", "Z"}
              set lCase to {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", ¬
                        "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", ¬
                        "u", "v", "w", "x", "y", "z"}
              set nbr to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
              set alnum to uCase & lCase & nbr
              set status to true as boolean
              repeat with charptr from 1 to count of username
                        set current_char to item charptr of username
      -- log current_char
                        if current_char is not in alnum then
                                  set status to false
      -- display dialog current_char
                                  exit repeat
                        end if
              end repeat
              return status
    end isalnum

  • Is there any max character length for index usage ?

    deleting this thread..
    Edited by: OraDBA02 on Oct 3, 2012 2:32 PM

    This is a fairly well documented issue. (At least, I documented it a few years ago in "CBO Fundamentals").
    Oracle only considers the first few bytes of a character string when calculating selectivity, so you can get all sorts of anomalous results.
    You could start by reading a couple of notes I wrote some time ago - this might give you a few pointers for your particular case:
    http://jonathanlewis.wordpress.com/2010/10/05/frequency-histogram-4/
    http://jonathanlewis.wordpress.com/2010/10/13/frequency-histogram-5/
    Regards
    Jonathan Lewis

Maybe you are looking for

  • Any way to block spam texts like blocking a ph #?

    Is there some way to block incoming texts addresses? Am I missing something? When I press on the text address, I'm not seeing a "Block" option, just the ability to Delete it.

  • OWB sees analytic function as aggregate function

    OWB 9.2: We use an analytic form of the REGR_SLOPE function (with the analytic clause specified) in an expression operator in a mapping. When validated, OWB gives an error, complaining a aggregate function is used. Can this bug be circumvented? Jaap.

  • Sql script

    I am trying to create a partitioning script for my erg_kwh_log table and i have this table in many schemas, what i want is the before running the partitions command a pl/sql block should check whether the existing table is partitioned or not, so for

  • Problem in content of editorpane

    Hi, In my application the editroPane have some content this content should be read in FileInputStream for that it should be saved as file.. How is this possible????????// whether the content may be saved as file or how this content should be read in

  • Aperture, Display and Printer Color Match/Profile Calibration ?

    I need to calibrate my HP Photosmart Plus B209a-m Printer to match what I see on my Acer X223w 22 inch display when using Aperture 3 and Photoshop CS5 The colors are pretty close to matching but each photo I print comes out deeper in color ( shadows