Dangling Meta Character*

Hi
I am getting following exception while executing this statement.can any body give anyt idea and how to fix this problem?
String sbr="this is kdfdanth redd*t from fdgkanth";
String bol=sbr.replaceAll("*"," ");
System.out.println("********* " + bol);
Exception in thread "main" java.util.regex.PatternSyntaxException: Dangling meta
character '*' near index 0
^
at java.util.regex.Pattern.error(Unknown Source)
at java.util.regex.Pattern.sequence(Unknown Source)
at java.util.regex.Pattern.expr(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.<init>(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.lang.String.replaceAll(Unknown Source)
at Max.main(Max.java:23)

in regular expression , a* means a,aa,....,aaaaa...a
u pass some other string other than wild characters like *,?.
the string u want to replace has * at its first place . even though the string has * at some other position like java*sun*com. it will not replace
* with ur specified string. it will treat a* and n* i.e a,aa,aa.. or n,nn,nn....

Similar Messages

  • 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\\+")

  • Dangling meta character exception

    Hi,
    we get this exception after a readAll query with conformResultsInUnitOfWork. The presence of the "+" in the text seems to confuse toplink.
    Is it a known bug or should we open a TAR?
    java.util.regex.PatternSyntaxException: Dangling meta character '+' near index 0
    +20019G KRUEGER RENATE.*
    ^
    at java.util.regex.Pattern.error(Pattern.java:1528)
    at java.util.regex.Pattern.sequence(Pattern.java:1645)
    at java.util.regex.Pattern.expr(Pattern.java:1545)
    at java.util.regex.Pattern.compile(Pattern.java:1279)
    at java.util.regex.Pattern.<init>(Pattern.java:1035)
    at java.util.regex.Pattern.compile(Pattern.java:779)
    at java.util.regex.Pattern.matches(Pattern.java:865)
    at oracle.toplink.internal.helper.JDK14Platform.conformLike(JDK14Platform.java:51)
    at oracle.toplink.internal.helper.JavaPlatform.conformLike(JavaPlatform.java:57)
    at oracle.toplink.expressions.ExpressionOperator.doesRelationConform(ExpressionOperator.java:769)
    at oracle.toplink.internal.expressions.RelationExpression.doesConform(RelationExpression.java:133)
    at oracle.toplink.publicinterface.UnitOfWork.getAllFromNewObjects(UnitOfWork.java:1493)
    at oracle.toplink.queryframework.ReadAllQuery.conformResult(ReadAllQuery.java:332)
    at oracle.toplink.queryframework.ReadAllQuery.registerObjectInUnitOfWork(ReadAllQuery.java:684)
    at oracle.toplink.publicinterface.UnitOfWork.internalExecuteQuery(UnitOfWork.java:2222)
    at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1086)
    at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1038)
    We use Toplink 9.0.4.4, jdk 1.4.

    This is a known bug. It will be fixed in TopLink 9.0.4.6.

  • AS2 Adapter Error

    Hi
    I need to send DATA from RFC to External partner I am using PI 7.4 AS2 (B2B)
    I am getting the below error in the As2 , I am using the below Module . please let me know what is causing the below issue
    localejbs/X12ConverterModule
    MP: exception caught with cause java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0
    ^
    Thanks
    Jai

    Hi Jai,
    The error is because incorrect regular expression is specified for the file name in receiver channel.
    Please check your receiver channel configuration. also refer the below thread
    Getting error "xml:java.util.regex.patternsyntaxexception dangling meta character '*' near index 0" while converting EDIFACT to XML
    regards,
    harish

  • Multiple Error Messages CFB2 after hotfix installation

    Hi,
    I just installed the CFB2 Hotfix on Windows 7 pro 64 AND 32bit machines and now get a ton of startup errors in the error log. I have no idea what is causing this. Here is a small part of the error log. I have tried starting with the -clean option and still get the errors. It's approx. 900 lines of messages.
    Any way to remove the cause of these?
    Thanks,
    Doug
    !ENTRY org.eclipse.equinox.preferences 4 4 2011-07-20 14:01:23.928
    !MESSAGE Exception loading preferences from: .
    !STACK 0
    org.osgi.service.prefs.BackingStoreException: Unable to determine provisioning agent from location: file:\2fC:\2fUsers\2fDoug\2fAppData\2fLocal\2fTemp\2fI1306347801\2fWindows\2fp2\2f
        at org.eclipse.equinox.internal.p2.engine.ProfilePreferences.getAgent(ProfilePreferences.jav a:159)
        at org.eclipse.equinox.internal.p2.engine.ProfilePreferences.load(ProfilePreferences.java:24 0)
        at org.eclipse.core.internal.preferences.EclipsePreferences.create(EclipsePreferences.java:3 07)
        at org.eclipse.core.internal.preferences.EclipsePreferences.internalNode(EclipsePreferences. java:543)
        at org.eclipse.core.internal.preferences.EclipsePreferences.node(EclipsePreferences.java:669 )
        at org.eclipse.core.internal.preferences.EclipsePreferences.internalNode(EclipsePreferences. java:549)
        at org.eclipse.core.internal.preferences.EclipsePreferences.node(EclipsePreferences.java:669 )
        at org.eclipse.core.internal.preferences.EclipsePreferences.internalNode(EclipsePreferences. java:549)
        at org.eclipse.core.internal.preferences.EclipsePreferences.node(EclipsePreferences.java:669 )
        at org.eclipse.core.internal.preferences.RootPreferences.getNode(RootPreferences.java:106)
        at org.eclipse.core.internal.preferences.RootPreferences.node(RootPreferences.java:85)
        at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.getPreferenc es(AbstractRepositoryManager.java:499)
        at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.remember(Abs tractRepositoryManager.java:857)
        at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.stop(Abstrac tRepositoryManager.java:1052)
        at org.eclipse.equinox.internal.p2.core.ProvisioningAgent.unregisterService(ProvisioningAgen t.java:121)
        .................... cut .................
    !SESSION 2011-07-20 14:01:34.716 -----------------------------------------------
    eclipse.buildId=unknown
    java.version=1.6.0_24
    java.vendor=Sun Microsystems Inc.
    BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
    Command-line arguments:  -os win32 -ws win32 -arch x86 -clean
    !ENTRY org.eclipse.equinox.p2.engine 4 4 2011-07-20 14:01:37.799
    !MESSAGE An error occurred while installing the items
    !SUBENTRY 1 org.eclipse.equinox.p2.engine 4 0 2011-07-20 14:01:37.799
    !MESSAGE session context was:(profile=profile, phase=org.eclipse.equinox.internal.p2.engine.phases.Install, operand=null --> [R]com.adobe.ide.coldfusion.search 2.0.0.277745, action=org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.InstallBundleAction).
    !SUBENTRY 1 org.eclipse.equinox.p2.touchpoint.eclipse 4 0 2011-07-20 14:01:37.799
    !MESSAGE The artifact file for osgi.bundle,com.adobe.ide.coldfusion.search,2.0.0.277745 was not found.
    ...... more .....
    !ENTRY org.eclipse.update.configurator 4 0 2011-07-20 14:01:38.686
    !MESSAGE Could not install bundle plugins/org.sat4j.pb_2.2.0.v20100429.jar   Bundle "org.sat4j.pb" version "2.2.0.v20100429" has already been installed from: reference:file:plugins/org.sat4j.pb_2.2.0.v20100429.jar
    !ENTRY org.eclipse.update.configurator 4 0 2011-07-20 14:01:38.687
    !MESSAGE Could not install bundle plugins/org.scriptaculous.1.8_1.8.0.00001.jar   Bundle "org.scriptaculous.1.8" version "1.8.0.00001" has already been installed from: reference:file:plugins/org.scriptaculous.1.8_1.8.0.00001.jar
    !ENTRY Extensions 1 0 2011-07-20 14:01:42.481
    !MESSAGE Dangling meta character '*' near index 0

    I just tried that on my 64-bit machine and get the following in my error.log. Note on the keybinding, I have NOT added or changed any keybindings, so don't know where that's coming from.
    !SESSION 2011-09-15 14:03:47.654 -----------------------------------------------
    eclipse.buildId=unknown
    java.version=1.6.0_24
    java.vendor=Sun Microsystems Inc.
    BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
    Command-line arguments:  -os win32 -ws win32 -arch x86 -clean
    !ENTRY org.eclipse.jface 2 0 2011-09-15 14:05:08.069
    !MESSAGE Keybinding conflicts occurred.  They may interfere with normal accelerator operation.
    !SUBENTRY 1 org.eclipse.jface 2 0 2011-09-15 14:05:08.069
    !MESSAGE A conflict occurred for ALT+CTRL+R:
    Binding(ALT+CTRL+R,
        ParameterizedCommand(Command(com.adobe.ide.coldfusion.shortcut.cfscript,Insert cfscript block,
            Insert cfscript block,
            Category(com.adobe.ide.coldfusion.commands,CFML Editor,null,true),
            com.adobe.ide.coldfusion.shortcut.handlers.CFScriptHandler,
            ,,true),null),
        cfscheme,
        com.adobe.ide.editor.cfml.context,,,user)
    Binding(ALT+CTRL+R,
        ParameterizedCommand(Command(com.adobe.ide.coldfusion.shortcut.cfscript,Insert cfscript block,
            Insert cfscript block,
            Category(com.adobe.ide.coldfusion.commands,CFML Editor,null,true),
            com.adobe.ide.coldfusion.shortcut.handlers.CFScriptHandler,
            ,,true),null),
        cfscheme,
        com.adobe.snippet.context,,,user)
    !ENTRY org.eclipse.osgi 2 1 2011-09-15 14:06:56.414
    !MESSAGE NLS unused message: CFMLKeysPreferencePage.0 in: com.adobe.ide.coldfusion.keyboard.preferences.messages
    !ENTRY org.eclipse.osgi 2 1 2011-09-15 14:06:56.415
    !MESSAGE NLS unused message: CFMLKeysPreferencePage.1 in: com.adobe.ide.coldfusion.keyboard.preferences.messages
    !ENTRY org.eclipse.osgi 2 1 2011-09-15 14:06:56.416
    !MESSAGE NLS unused message: CFMLKeysPreferencePage.4 in: com.adobe.ide.coldfusion.keyboard.preferences.messages
    !SESSION 2011-09-15 14:08:36.899 -----------------------------------------------
    eclipse.buildId=unknown
    java.version=1.6.0_24
    java.vendor=Sun Microsystems Inc.
    BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
    Command-line arguments:  -os win32 -ws win32 -arch x86 -clean
    !ENTRY org.eclipse.jface 2 0 2011-09-15 14:08:41.807
    !MESSAGE Keybinding conflicts occurred.  They may interfere with normal accelerator operation.
    !SUBENTRY 1 org.eclipse.jface 2 0 2011-09-15 14:08:41.807
    !MESSAGE A conflict occurred for ALT+CTRL+R:
    Binding(ALT+CTRL+R,
        ParameterizedCommand(Command(com.adobe.ide.coldfusion.shortcut.cfscript,Insert cfscript block,
            Insert cfscript block,
            Category(com.adobe.ide.coldfusion.commands,CFML Editor,null,true),
            com.adobe.ide.coldfusion.shortcut.handlers.CFScriptHandler,
            ,,true),null),
        cfscheme,
        com.adobe.snippet.context,,,user)
    Binding(ALT+CTRL+R,
        ParameterizedCommand(Command(com.adobe.ide.coldfusion.shortcut.cfscript,Insert cfscript block,
            Insert cfscript block,
            Category(com.adobe.ide.coldfusion.commands,CFML Editor,null,true),
            com.adobe.ide.coldfusion.shortcut.handlers.CFScriptHandler,
            ,,true),null),
        cfscheme,
        com.adobe.ide.editor.cfml.context,,,user)
    !SESSION 2011-09-16 13:43:24.117 -----------------------------------------------
    eclipse.buildId=unknown
    java.version=1.6.0_24
    java.vendor=Sun Microsystems Inc.
    BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
    Command-line arguments:  -os win32 -ws win32 -arch x86 -clean
    !ENTRY org.eclipse.jface 2 0 2011-09-16 13:43:31.062
    !MESSAGE Keybinding conflicts occurred.  They may interfere with normal accelerator operation.
    !SUBENTRY 1 org.eclipse.jface 2 0 2011-09-16 13:43:31.062
    !MESSAGE A conflict occurred for ALT+CTRL+R:
    Binding(ALT+CTRL+R,
        ParameterizedCommand(Command(com.adobe.ide.coldfusion.shortcut.cfscript,Insert cfscript block,
            Insert cfscript block,
            Category(com.adobe.ide.coldfusion.commands,CFML Editor,null,true),
            com.adobe.ide.coldfusion.shortcut.handlers.CFScriptHandler,
            ,,true),null),
        cfscheme,
        com.adobe.snippet.context,,,user)
    Binding(ALT+CTRL+R,
        ParameterizedCommand(Command(com.adobe.ide.coldfusion.shortcut.cfscript,Insert cfscript block,
            Insert cfscript block,
            Category(com.adobe.ide.coldfusion.commands,CFML Editor,null,true),
            com.adobe.ide.coldfusion.shortcut.handlers.CFScriptHandler,
            ,,true),null),
        cfscheme,
        com.adobe.ide.editor.cfml.context,,,user)
    !SESSION 2011-09-19 10:18:43.271 -----------------------------------------------
    eclipse.buildId=unknown
    java.version=1.6.0_24
    java.vendor=Sun Microsystems Inc.
    BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
    Command-line arguments:  -os win32 -ws win32 -arch x86 -clean
    !ENTRY org.eclipse.equinox.p2.engine 4 4 2011-09-19 10:18:55.798
    !MESSAGE An error occurred while committing the engine session for profile: profile.
    !SUBENTRY 1 org.eclipse.equinox.p2.touchpoint.eclipse 4 0 2011-09-19 10:18:55.798
    !MESSAGE
    !SUBENTRY 2 org.eclipse.equinox.p2.touchpoint.eclipse 4 0 2011-09-19 10:18:55.798
    !MESSAGE Error saving manipulator.
    !STACK 0
    java.lang.NullPointerException
        at org.eclipse.equinox.internal.frameworkadmin.equinox.EquinoxFwConfigFileParser.saveFwConfi g(EquinoxFwConfigFileParser.java:489)
        at org.eclipse.equinox.internal.frameworkadmin.equinox.EquinoxManipulatorImpl.save(EquinoxMa nipulatorImpl.java:407)
        at org.eclipse.equinox.internal.p2.touchpoint.eclipse.LazyManipulator.save(LazyManipulator.j ava:96)
        at org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint.saveManipulator(Ecli pseTouchpoint.java:61)
        at org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint.commit(EclipseTouchp oint.java:137)
        at org.eclipse.equinox.internal.p2.engine.EngineSession.commit(EngineSession.java:123)
        at org.eclipse.equinox.internal.p2.engine.Engine.perform(Engine.java:91)
        at org.eclipse.equinox.internal.p2.engine.Engine.perform(Engine.java:44)
        at org.eclipse.equinox.internal.p2.reconciler.dropins.ProfileSynchronizer.executePlan(Profil eSynchronizer.java:720)
        at org.eclipse.equinox.internal.p2.reconciler.dropins.ProfileSynchronizer.performAddRemove(P rofileSynchronizer.java:173)
        at org.eclipse.equinox.internal.p2.reconciler.dropins.ProfileSynchronizer.synchronize(Profil eSynchronizer.java:128)
        at org.eclipse.equinox.internal.p2.reconciler.dropins.Activator.synchronize(Activator.java:4 19)
        at org.eclipse.equinox.internal.p2.reconciler.dropins.Activator.start(Activator.java:176)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:7 83)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextIm pl.java:774)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:7 55)
        at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:370)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:374)
        at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1067)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManage r.java:561)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManage r.java:546)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java :459)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelMana ger.java:243)
        at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManage r.java:440)
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:227)
        at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:337)
    !ENTRY org.eclipse.jface 2 0 2011-09-19 10:19:16.671
    !MESSAGE Keybinding conflicts occurred.  They may interfere with normal accelerator operation.
    !SUBENTRY 1 org.eclipse.jface 2 0 2011-09-19 10:19:16.671
    !MESSAGE A conflict occurred for ALT+CTRL+R:
    Binding(ALT+CTRL+R,
        ParameterizedCommand(Command(com.adobe.ide.coldfusion.shortcut.cfscript,Insert cfscript block,
            Insert cfscript block,
            Category(com.adobe.ide.coldfusion.commands,CFML Editor,null,true),
            com.adobe.ide.coldfusion.shortcut.handlers.CFScriptHandler,
            ,,true),null),
        cfscheme,
        com.adobe.snippet.context,,,user)
    Binding(ALT+CTRL+R,
        ParameterizedCommand(Command(com.adobe.ide.coldfusion.shortcut.cfscript,Insert cfscript block,
            Insert cfscript block,
            Category(com.adobe.ide.coldfusion.commands,CFML Editor,null,true),
            com.adobe.ide.coldfusion.shortcut.handlers.CFScriptHandler,
            ,,true),null),
        cfscheme,
        com.adobe.ide.editor.cfml.context,,,user)
    !ENTRY org.eclipse.ui 4 4 2011-09-19 10:20:08.432
    !MESSAGE Category com.adobe.model.editor.views not found for view com.adobe.rds.client.core.views.DatabaseView.  This view added to 'Other' category.
    !ENTRY org.eclipse.ui 4 4 2011-09-19 10:20:08.432
    !MESSAGE Category com.aptana.ide.documentation not found for view com.aptana.ide.documentation.jquery.visualjquery.  This view added to 'Other' category.
    !ENTRY org.eclipse.ui 4 4 2011-09-19 10:20:08.432
    !MESSAGE Category com.aptana.ide.documentation not found for view com.aptana.ide.documentation.libraryname.sampleview.  This view added to 'Other' category.
    !ENTRY org.eclipse.ui 4 4 2011-09-19 10:20:08.447
    !MESSAGE Category com.adobe.model.editor.views not found for view com.adobe.rds.client.core.views.DatabaseView.  This view added to 'Other' category.
    !ENTRY org.eclipse.ui 4 4 2011-09-19 10:20:08.447
    !MESSAGE Category com.aptana.ide.documentation not found for view com.aptana.ide.documentation.jquery.visualjquery.  This view added to 'Other' category.
    !ENTRY org.eclipse.ui 4 4 2011-09-19 10:20:08.447
    !MESSAGE Category com.aptana.ide.documentation not found for view com.aptana.ide.documentation.libraryname.sampleview.  This view added to 'Other' category.

  • How to create a regex for the question mark as a literal?

    I get:
    Exception in thread "main" java.util.regex.PatternSyntaxException: Dangling meta character '?' near index 3
    (?)?For
    (\p{Punct})?
    and (\\?)?
    and (\\'?')?

    simpatico_gabriele wrote:
    I get:
    Exception in thread "main" java.util.regex.PatternSyntaxException: Dangling meta character '?' near index 3
    (?)?For
    (\p{Punct})?
    and (\\?)?
    and (\\'?')?Sorry but, as Darryl says, you need to explain your problem a bit better because the patterns
            Pattern p0 = Pattern.compile("(\\p{Punct})?");
            Pattern p1 = Pattern.compile("(\\?)?");
            Pattern p2 = Pattern.compile("(\\'?')?");all compile and run without any exception.

  • Regex and implementing FilenameFilter problem

    Hello,
    So what I'm trying to do is to create a program that takes a certain set of files, pulls the first line of each file and uses it to name the file. Right now, I'm at the point of getting a listing of files based on a patterns. So when I run the program on the command line (of a windows machine), it spit out the files that I'm looking for. Something like:
    java FileRenamer *.txt
    Above should produce a listing of only files that have .txt on them (I want to have the capability to choose *.txt or whatever other combination of pattern match).
    To do the above, I want to use a FileNameFilter interface to figure out what files match. The problem that I'm running into is that when I run a unit test against the getFilesListBasedOnPattern method, I get:
    java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0
    *.txt
    The problem is that the *.txt has a regex character (the *) and I'm not sure how make it behave like the wildcard in the dos command line where *.txt means everything that has .txt at the end.
    The code listing is below. Does anyone have any suggestions on how to best approach this?
    mapsmaps
    =======> Code below <=======
    // unit test snippet that causes blow out:
    FileRenamer fr = new FileRenamer();
    String [] strArrFilesBasePattern = fr.getFilesListBasedOnPattern(dirTestFiles,"*.txt");
    ====
    //main program
    package com.foo.filerenamer;
    import java.io.File;
    import java.io.FilenameFilter;
    import java.util.Vector;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    * TODO Use regexp to filter out input to *.txt type of thing or nothing else
    public class FileRenamer
        // Vallid file patterns are *.*, ?
        public static final String strVALIDINPUTCHARS = "[_.a-zA-Z0-9\\s\\*\\?-]+";
        private static Pattern regexPattern = Pattern.compile(strVALIDINPUTCHARS);
        private static Matcher regexMatcher;
         * @param args
         * @throws InterruptedException
        public static void main(String[] args) throws InterruptedException
            int intMillis = 0;
            if (args.length > 0)
                try
                    intMillis = Integer.parseInt(args[0]);
                    System.out.println("Sleep set to " + intMillis + " seconds");
                catch (NumberFormatException e)
                    intMillis = 5000;
                    System.out.println("Sleep set to default of " + intMillis + " since first parameter was non-int");
                for (int i=0;i<args.length;i++)
                    System.out.println("hello there - args["+i+"] = "+ args);
    Thread.sleep(intMillis);
    // TODO Auto-generated method stub
    public boolean checkArgs(String [] p_strAr)
    boolean bRet = false;
    if (p_strAr.length != 1)
    return false;
    else
    regexMatcher = regexPattern.matcher(p_strAr[0]);
    bRet = regexMatcher.matches();
    return bRet;
    public String[] getFilesListBasedOnPattern(File p_dirFilesLoc, String p_strValidPattern)
    String[] strArrFilteredFileNames = p_dirFilesLoc.list(new RegExpFileFilter(p_strValidPattern));
    return strArrFilteredFileNames;
    class RegExpFileFilter implements FilenameFilter
    private String m_strPattern = null;
    private Pattern m_regexPattern;
    public RegExpFileFilter(String p_strPattern)
    m_strPattern = p_strPattern;
    m_regexPattern = Pattern.compile(m_strPattern);
    public boolean accept(File m_directory, String m_filename)
    if (m_regexPattern.matcher(m_filename).matches())
    return true;
    return false;

    I am doing something similar but have a problem with Java automatically converting wildcards in path-arguments to the first match (!).
    It seems the JVM is applying some intelligence here and checks if a path is passed to main() and if so, it automatically resolves wildcards (also quotes are escaped/resolved), which is pretty annoying and not what I want, since I do never see the original parameters this way:(
    Is there a way to get the original parameters without the JVM intervening / "helping"?
    Any help would be appreciated, as I want my utility to act just like any other shell-program...

  • Replace "+%5Cn" with "%0D%0A"

    Hi, i need to replace "+%5Cn" with "%0D%0A" in a encoded message. I used replaceAll() function but it return me this runtine exception "java.util.regex.PatternSyntaxException: Dangling meta character '+' near index 0+%5Cn". The same thing happen when i try to replace "\" with "\\" in a message. Can anyone advice me how to solve this problem? Thanks in advance.

    Just to clarify a bit, the first replacement would be done like this:  message = message.replaceAll("\\+%5Cn", "%0D%0A");and the second like this:  message = message.replaceAll("\\\\", "\\\\");I know that one looks bizarre, but it's because both the Java compiler and the Pattern class will process the first argument, and both use the backslash as an escape character.

  • Incomprehensible error (regex)

    Hi all,
    There I was, happily tap-tapping away in Java, sipping on my Diet Coke and wondering if tonights episode of The Simpsons would be one I'd seen or not, when blam!.....Up pops this error, which means nothing to me (since I've not really covered regular expressions yet).
    java.util.regex.PatternSyntaxException: Dangling meta character '+' near index 0
    +
    ^
    at java.util.regex.Pattern.error(Pattern.java:1528)
    at java.util.regex.Pattern.sequence(Pattern.java:1645)
    at java.util.regex.Pattern.expr(Pattern.java:1545)
    at java.util.regex.Pattern.compile(Pattern.java:1279)
    at java.util.regex.Pattern.<init>(Pattern.java:1035)
    at java.util.regex.Pattern.compile(Pattern.java:779)
    at java.lang.String.replaceAll(String.java:1663)
    at Utility.stripOut(Utility.java:47)
    at TryUtility.main(TryUtility.java:14)
    Exception in thread "main"
    The code in question is this: -
            String sString = "+02:00";
            sString = Utility.stripOut(sString, "+");
            System.out.println(sString);...using this static method....
        // Strips out all occurances of sWhat from string sFrom.
        public static String stripOut(String sFrom, String sWhat) {
            if ((sFrom == null) || (sFrom.length() < 1) || (sWhat.length() < 1)) {
                return null;
            } else {
                return sFrom.replaceAll(sWhat, "");
        }All it should do is strip out a chosen character or string from another string and return the modifed result. Shouldn't be too hard :)
    BTW, line 47 from the stacktrace is the method return line of the stripOut() method and line 14 is the calling line from the execution code.
    I don't really see what the problem is with stripping out the '+' sign from the String, but as I said, I've not really done much with reg expressions yet, so any advice / info would be useful.
    Thanks.

    Thanks very much guys.....I didn't realise that using replaceAll actually fell within the realms of regular expressions. :)

  • Ava.util.regex.pattern and * - + /

    hi...
    i'm korean... so I can't speak english.. sorry..^^
    but i hava a problem..
    import java.util.regex.*;
    public class Operator
    /     public static void main(String args[])
              String operator="/";
    ////////////////////////////////////////////////////////////// error point..
              Pattern pattern=Pattern.compile(operator);
              Matcher m=pattern.matcher("- ----* / */* /+");
              int count=0;
              while(m.find()) {
         count++;
              System.out.println(count);
    Exception in thread "main" java.util.regex.PatternSyntaxException: Dangling meta character '+' near index 0
    +
    operator : / - : ok...
    operator : * + : error...
    i had to use + *..
    what's problem??

    Are you using matches()? Then keep in mind that it requires that the entire String is matched by the RE.
    pattern.matcher("about:foobar").matches(); //will return false, as "foobar" is not matched by your pattern
    pattern.matcher("about:").matches(); //will return true
    pattern.matcher("about:foobar").find(); //will return true
    pattern.matcher("notabout:foobar").find(); // will return false

  • Pattern Exception

    HI All
    I am developing a semi seach engine. I want to split the string using (+) operator. I write the following code:
              } else if( source.contains("+")) {
                words = source.split("+");
                for ( String str : words ) {
                    out.println( str );
    When running the program, I got the following exception:
    Exception in thread "AWT-EventQueue-0" java.util.regex.PatternSyntaxException: Dangling meta character '+' near index 0
    +
    Any help will be appreciated
    Thank you

    split() uses a "regular expression" as its argument and "+" is a symbol in
    these. You would have to split withsource.split("\\+");

  • PatternSyntaxException w/ replaceAll

    String msg="what is up?";
    String[] s = msg.split(" ");
    String[] r = {"?","!",",",".","+"};
    for(int i=0;i<s.length;i++){
         for(int j=0;j<r.length;j++){
              if(s.contains(r[j])){
    s[i]=s[i].replaceAll(r[j], "");
    Throws: Exception in thread "main" java.util.regex.PatternSyntaxException: Dangling meta character '?' near index 0 @ the replaceAll
    Some googling showed that adding "\\" in front of the ? should fix it. But this doesn't seem to work. (IE r = {"\\?","!",",",".","+"}; )
    It doesn't see that "\\?" is contained.
    So I removed the check for containing...
    String msg="what is up?";
    String[] s = msg.split(" ");
    String[] r = {"\\?","!",",",".","\\+"};
    for(int i=0;i<s.length;i++){
         for(int j=0;j<r.length;j++){
              s=s[i].replaceAll(r[j], "");
    System.out.println(s[i]);
    It prints out nothing.
    So some how, s[i] is empty after it replaces everything. I don't understand what's happening.
    How can i remove these characters from my String?

    Oops: Watch your dot ;-) replaceAll(".", "") removes all chacters from the string (except EOL's by default).
    class Replacerator
      public static void main(String[] args) {
        try {
          for ( String word : "What's up?".split(" ") ) {
            word = word.replaceAll("(?<=[A-Za-z])'s", " is");
            for ( String replacement : new String[]{"\\?", "!", ",", "\\.", "\\+"} ) {
              word = word.replaceAll(replacement, "");
            System.out.println(word);
        } catch (Exception e) {
          e.printStackTrace();
    }Cheers. Keith.

  • HOW TO REPLACE  THIS

    Hi
    Form
    Can somebody Tell me where am i doing Wrong
    if(WordPlus.startsWith("+~")) {
    WordPlus = WordPlus .replaceAll( "+~" , "+" );
    At run time the Execption is produced
    java.util.regex.PatternSyntaxException: Dangling meta character '+' near index 0
    thx in advance

    Hi
    Form
    I Used the StringBuffer Replace ment Factor something like this
    as u advised but something turns up wrong in the 3rd and 4th if Condition
    The code is as below
    public string getReplace( String Word){
    String WordPlus = "",WordMinus = "";
    if(Word.startsWith("+~"){
    StringBuffer splus = new StringBuffer(Word);
    WordPlus = (splus.delete(0,2)+"")+trim();
    if(Word.startsWith("-~"){
    StringBuffer sminus = new StringBuffer(Word);
    WordMinus = (sminus .delete(0,2)+"")+trim();
    if(Word.startsWith("+"){
    if(Word.startsWith("-"){
    Word = "+" + WordPlus + "-" + WordMinus ;
    return Word;
    It the I/p is "+~Roses~"
    O/p is "+Roses~"
    but if I/p is "+Roses~
    O/p does not Reply any thing.
    Please Help me
    thx in advace

  • Trouble with Regex

    Hi,
    I need to check whether a String contains any of these characters
    ()<>!=+-%|*/'",:I am not able to put all these in the Pattern.compile method. I am getting different errors like "Illegal character range" or "Dangling meta character". I tried many times adding backward slashes with the characters, but didn't work.
    Can anybody help?
    Regards,
    Swapna.

    You can use the \Q \E to escape it all e.g.
           Pattern p = Pattern.compile("[\\Q()<>!=+-%|*/'\",:\\E]");
            Matcher m = p.matcher("<>");
            if (m.find())
                System.out.print("containes at leas one of ()<>!=+-%|*/'\",:");
            }I seem to remember that an earlier post by uncle_alice indicated that \Q and \E had bugs in JDK1.4 but that it is OK in JDK1.5 .

Maybe you are looking for

  • HT1423 what memory is best for mac

    what memory is best for mac

  • USB MIDI Controller no longer working after Logic 8 upgrade

    Hello, my M-Audio O2 USB MIDI Controller worked brilliantly with Logic Pro 7 after simply plugging it in. I never needed to install any drivers or do any setup. Now, after upgrading to Logic Pro 8 it isn't recognized and does not work. Does anyone kn

  • All apple products I cannot send outgoing message

    My IPhone and my Ipad both receive messages, texts etc. However when I respond to anyone via email it says my email address or password is incorrect. I've deleted the account, rebooted. What's up and how can I fix this?

  • Additional tab will not open for links

    previously i have been able to click on a link, and the link would open in a new window or tab. but now whenever i try to open a link through a website, it will not open the link in a new window or new tab. how can i fix this?

  • Old NFS Volumes are a problem in finder

    Hi, I mount an nfs volume and work on files that are saved on it. I do this manually in finder->Go->Connect to server Sometimes it gets disconnected so I do that again, but there is a problem. The previous volume still exists in the directory. You ca