Using special chars in RegEx causes problems

Hello Folks,
I have a single string of numbers positive and negative separated by a delimiter. I am trying to convert the negative numbers which are represented by brackets into ones without brakcets e.g. (1.235) to -1.235
Here is what I have in my code
               arCols[j].replaceAll("\(", "-");
               arCols[j].replaceAll("\)", "");
But that gives a compilation problem as below.
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
     Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )
And if I remove the leading slash that tries to escape the character as below
               arCols[j].replaceAll("(", "-");
               arCols[j].replaceAll(")", "");
I get the following error.
Exception in thread "main" java.util.regex.PatternSyntaxException: Unclosed group near index 1
How can I replace the brackets using regular expression search and replace?
Thanks for your help.
Sanjay.

You need
arCols[j] = arCols[j].replaceAll("\\(", "-");
arCols[j] = arCols[j].replaceAll("\\)", "");because
a) String objects are immutable
and b) you need to escape the '(' and ')' .
P.S. With a bit of thought this could be done in one single regex
System.out.println("fasdf(123.4)faf fdf(246.8) fafasd 1.23".replaceAll("\\(([^\\)]*)\\)","-$1"));Edited by: sabre150 on Oct 2, 2007 7:32 AM

Similar Messages

  • REPORT S_ALR_87013558 - NOT ABLE TO USE SPECIAL CHAR(*,+) IN PROJECT DEF

    Hi to all,
    when using standard report S_ALR_87013558 , i don't manage to use special characters such as * or + . Do i need to apply a note or set something in customizing?
    Thanks for your help.
    Ciao, Carlo

    Hi Carlo,
    The customizing for using special characters is found in OPSK tcode. It is called "Define Special Characters for Project".
    Ciao,
    Dave

  • Special characters like hyphens cause problems in Text to Speech on Mac

    The Text to Speech function with the shortcut [option+esc] has helped me  a lot. But, the only problem is that when there is a hyphen in the paragraph selected it doesn't even start reading the paragraph.
    This problem occurs when reading pdf files from the chrome using TTS.

    I thought that perhaps that I might be able to do something like make the iPod screen have a white text on black mode (like in the Mac OS X accessability mode), would this be possible?
    Can anyone else think of anything when using an iPod to help vision impaired people to use an iPod?
    Cheers,
    Nicholas

  • Using x less then y causing problems

    I want to use x
    Attachments:
    forum.doc ‏39 KB

    OK, I see. You want to repeat the code in sequence 1 of the blue little stacked sequence frame until the velocity is less than 20.
    This is very easy with a while loop. See image (Sorry, I no longer have LabVIEW 6.0 installed).
    Message Edited by altenbach on 08-22-2005 07:40 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    while.png ‏12 KB

  • SLM2048 - Password problems with special chars

    Hi all,
    We´ve got a SLM2048 in use  (most current FW) and I wanted to apply our new password standards  onto that switch. So I changed the password of the user admin and used  special chars, which were =&!= and clicked update and save changes. I  now know, that I should have been using only alphanumerical characters,  but why is there no routine that checks the PW for conformance, before  writing it onto the switch.
    Problem now is, that I am unable to login and  don´t want to do a hard reset, because the configuration would be lost. I  know there should have been a rescue admin user, but there is none.  What can I do now? Any chance that a cisco engineer could get in contact  with me to debug the entered password in the lab and who could then  tell me what was saved to ROM or how I can login again?
    Thanks,
    Philip

    If your switch has a console port, you can try this:
    http://www.opendreams.net/jesse/doc/linksys_srw_switch_password_recovery.txt
    http://www.cisco.com/en/US/products/ps9967/products_qanda_item09186a0080a36735.shtml
    HTH,
    Andrew Lissitz

  • Problem with special chars in BLOB datatype using contains keyword

    Facing problem, when part searching with special chars in BLOB datatype. It is considering the non alpha-numeric chars as a separtor in a provided string
    EX:
    SELECT *
    FROM RESUME_TEST P,grst_candidate d
    WHERE d.candidate_id = p.candidate_id
    AND CONTAINS(P.CAND_RESUME,'%VB.NET%',1) > 0
    Strings: , VB.NET , PL/SQL AS/400 , C etc..
    Followed the below approaches
    1) created a table:
    Syntax: create table resume_Test(cand_id number(10),cand_resume blob);
    2) inserted the values into this table upto 60,000
    3) created a context index
    3.1 created preferences
    Syntax:
    BEGIN
    ctx_ddl.create_preference('try_lexer3','BASIC_LEXER');
    ctx_ddl.set_attribute('try_lexer3','printjoins','-_~!@#$%^&*(){}[],=?\;|><.+');
    END;
    3.2 created context index
    Syntax:
    CREATE INDEX CANDRESUME_CTX_IDX ON resume_test (cand_resume)
    INDEXTYPE IS CTXSYS.CONTEXT
    PARAMETERS ('LEXER try_lexer3 memory 500M');
    4) while executing this index, it is taking much time approx 6 hrs(plz explain why it is taking time)
    5) Problems:
    5.1 when searching with string(VB.NET , PL/SQL AS/400 , C etc..) it is considering the special char as a separator
    5.2 used escape char (\) also, but no effect
    5.3 when searching with single char, it is giving error (ORA-29902,ORA-20000,DRG-51030)
    5.4 getting the above error with wild card chars (& ,_, (),{},[])
    So, please explain the clear scenarios, why am getting this error , and how to get the proper results.

    Have you tried adding the / char to the printjoin characters?
    Indexing can take a lot of time, depending on the amount of data and your machine's power. You could try to parallelize the index creation and / or assign more memory
    CREATE INDEX CANDRESUME_CTX_IDX ON resume_test (cand_resume)
    INDEXTYPE IS CTXSYS.CONTEXT
    PARAMETERS ('LEXER try_lexer3 memory 2000M') PARALLEL 8;

  • Spliting a large string using regular expression which contain special char

    I have huge sting(xml) containing normal character a-z,A-Z and 0-9 as well as special char( <,>,?,&,',",;,/ etc.)
    I need to split this sting where it ends with </document>
    for e.g.
    Original String:
    <document>
    <item>sdf</item>
    <item><text>sd</text</item>
    </document>
    <document>hi</document>
    The above sting has to be splited in to two parts since it is having two document tag.
    Can any body help me to resolve this issue. I can use StringTokenizer,String split method or Regular expression api too.

    manas589 wrote:
    I used DOM and sax parser and got few exception. Again i don't have right to change xml. so i thought to go with RegularExpression or some other way where i can do my job.If the file actually comes in lines like what you posted, you should just be able to compare the contents of each line to see if it contains "</document>" or whatever you're looking for. I wouldn't use regex unless I needed another problem.
    I got excpetion like: Caused by: org.xml.sax.SAXParseException: The entity "nbsp" was referenced, but not declared.
         at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
         at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
         at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)So then it isn't even XML.
    Edit: sorry, I just realized why you're considering all of these heavy-duty ideas. It's just that you don't know how to break the string into lines. You do it like this:
    BufferedReader  br = new BufferedReader(new StringReader(theNotXMLString));

  • Getting parameters from URL: use of Special Chars

    I'm unable to retrieve the Special Chars from URL parameters.  Does someone have an idea where to look for?
    Examples where no Special Chars is retrieved :
    ...App?param=Aménagement
    ...App?param=Am<é>nagement
    ...App?param=Am%E9nagement
    I'm using this code :
              IWDProtocolAdapter protocolAdapter =
                   WDProtocolAdapter.getProtocolAdapter();
              IWDRequest request = protocolAdapter.getRequestObject();
                                    String param = request.getParameter("param");
    Thanks!

    okay, So if I use :
    ...App?param=Am%E9+nagement
    How would you then integrate URLDecoder.decode in the following code?
    IWDProtocolAdapter protocolAdapter =
         WDProtocolAdapter.getProtocolAdapter();
    IWDRequest request = protocolAdapter.getRequestObject();
    String param = request.getParameter("param");

  • I have two Iphones with different email addresses sharing one Apple ID. Will that cause problems with using messaging and FaceTime?

    I have two Iphones 5 with different email addresses sharing one Apple ID account.Both are using IOS 8.
    I would like to set up a new Apple Id for one of the phones and remove it from the old account.
    If I do that, can I move all of the purchased apps and songs to the new Apple account?
    Also, will sharing one Apple ID account with two devices cause problems with using messaging and FaceTime?

    Sharing an iCloud account between two devices can be done without causing issues with iMessage and FaceTime, just go into Settings for each of these functions and designate separate points of contact (i.e. phone number only, or phone number and unique email address).  While that works, you'll then face the problem where a phone call to one iPhone will ring both if on the same Wi-Fi network -- but again, that can be avoided by changing each phone's settings.
    Rather than do all that, don't fight it -- use separate IDs for iCloud.  You can still use a common ID for iTunes purchases (the ID for purchases and iCloud do not have to be the same) or you can use Family Sharing to share purchases from a primary Apple account.

  • TS3579 I found this useful because I did not know about the effect of typing in data and that you could only drag to rearrange the data.  I had typed in data before and this had caused problems but restoring defaults did not cause correct dates to show up

    I found this  (TS3579: If the wrong date or time is displayed in some apps on your Mac Learn about If the wrong date or time is displayed in some apps on your Mac) useful because I did not know about the effect of typing in data and that you could only drag to rearrange the data.  I had typed in data before and this had caused problems but restoring defaults did not cause correct dates to show up in Finder. 

    It sounds like there are a couple things going on here.  First check if you have a successful install of SQL Server, then we'll figure out the connection issues.
    Can you launch SQL Server Configuration Manager and check for SQL Server (MSSQLSERVER) if default instance or SQL Server (other name) if you've configured your instance as a named instance.  Once you find this, make sure the service is started. 
    If not started, try to start it and see if it throws an error.  If you get an error, post the error message your hitting.  If the service starts, you can then launch SSMS and try to connect.  If you have a default instance, you can use the machine
    name in the connection dialog.  Ex:  "COWBOYS" where Cowboys is the machine name.  However, if you named the SQL Server instance during install, you'll need to connect using the machine\instance format.  Ex:  COWBOYS\Romo (where Romo
    is the instance name you set during install).
    You can also look at the summary.txt file in the SQL Server setup error logs to see what happened on the most recent install.  Past install history is archived in the log folder if you need to dig those up to help troubleshoot, but the most
    recent one may help get to the bottom of it if there is an issue with setup detecting a prior instance that needs to be repaired.
    Thanks,
    Sam Lester (MSFT)
    http://blogs.msdn.com/b/samlester
    This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click
    "Mark as Answer" and
    "Vote as Helpful" on posts that help you. This can be beneficial to other community members reading the thread.

  • I replaced my hard drive and used time machine to boot from but it installedthe unrepaired disk permissions of the faulty previous drive would this cause problems on my new drive?

    I replaced my hard drive on macbook pro and used time machine to boot from but it also installed the unrepaired disk permmissions of the other drive, would this cause problems to my new drive?

    Can you remember what the permissions problem was that you had before? You may need to reinstall OS X from scratch and not reinstall anything from your Time Machine backups. To be on the safe side you should reinstall all third-party applications from scratch, as well. Then only restore from your backup your document/data files.

  • Problems with using special characters in Interactive Report Search

    Hi!
    I am currently developing an Application on Application Express 3.1.2.00.02 including a page with an Interactive Report, facing the problem that I cannot use special german characters in the Searchbar.
    So if i try to find a name like 'Schröder' the created Filter looks like this 'Schröder' and i won't get any valid search results. By the way the rest of the application supports these special characters like using them in Buttons or any other Page elements.
    Does anyone have a clue how to fix this problem, because it's driving me nuts ;)
    Thanks in advance
    Philipp
    Edited by: philipp_m on 10.06.2009 11:15

    Does noybody have a clue how to solve this problem. I tried to find out where the Problem occures. The Ajax Request looks like this
    f01     contains
    f01     Schröder
    f01     15
    p_flow_id     100
    p_flow_step_id     50
    p_instance     3176950818119673
    p_request     APXWGT
    p_widget_action     QUICK_FILTER
    p_widget_action_mod     ADD
    p_widget_mod     ACTION
    p_widget_name     worksheet
    p_widget_num_return     15
    x01     14175446766823030
    x02     14176526259823035
    So I guess it has to be inside the Javascript file (apex_ns_3_1.js). I hope someone can help me.
    Bye
    Philipp

  • Recently purchased a used IPad 2 but it still has previous owner's data.  I've been told not to sync it to my computer as it will cause problems.  What do I need to do to make it compatible with accounts on my mac and ipod touch?

    Recently purchased a used IPad 2 but it still has previous owner's data.  I've been told not to sync it to my computer as it will cause problems.  What do I need to do to make it compatible with accounts on my mac and ipod touch?  Thanks for any and all help!

    You can wipe the iPad's contents completely by going to Settings>General>Reset>Erase All Content and Settings. This will remove all of the previous user's apps, data, settings and so on from the iPad and you can set it up as your own.

  • Will multiple Lan cards cause problems using rmi?

    Will multiple Lan cards cause problems using rmi? If a host has two or more network cards (only one of which is Internet-enabled), how does RMI know which IP address to use? There seems to be a problem when such a client registers with an RMI service, and has a client-side callback method invoked by the server.

    You can tell RMI the address you want by defining java.rmi.server.hostname at the JVM which exports the remote object.

  • Do I use same oracle account on 2 cluster nodes cause problem?

    Do I use same oracle account on 2 cluster nodes cause problem?
    If I use same oracle account on 2 cluster nodes running 2 database, when failover happens, 2 database will be running on one node, does 2 oracle account make SHM ... memory conflict?
    or do I have to use oracle01 account on node1, oracle02 account on node2? Can not use same name account?
    Thanks.

    I'm not 100% certain I understood the question, so I'll rephrase them and answer them.
    Q. If I have the same Oracle account on each cluster node, e.g. uid=100 (oracle) gid=100 (oinstall), groups dba=200, can I run two databases, one on each cluster node without problems?
    A. Yes. Having multiple DBs on one node is not a problem and doesn't cause shared memory problems. Obviously each database needs a different database name and thus different SID.
    Q. Can I have two different Oracle accounts on each cluster node e.g. uid=100 (oraclea) gid=100 (oinstall), groups dba=200 and e.g. uid=300 (oracleb) gid=100 (oinstall), groups dba=200, and run two databases, one for each Oracle user?
    A. Yes. The different Oracle user names would need to be associated with different Oracle installations, i.e. Oracle HOMEs. So you might have /oracle/oracle/product/10.2.0/db_1 (oraclea) and /oracle/oracle/product/11.0.1.0/db_1 (oracleb). The ORACLE_HOME is then used to determine the Oracle user name by checking the user of the Oracle binary in the ${ORACLE_HOME}/bin directory.
    Tim
    ---

Maybe you are looking for

  • Shut down and restart buttons don't work

    About 3 weeks ago, and co-incidentally, following installing some Windows updates, I could no long shut down my computer nor activate the restart function when clicking on the shut down or restart buttons. The hibernate button does works.

  • Page Up and Down keys won't work - have tried everything

    My Page Up and Down keys won't work. I've tried hitting F7, the Fn key, checked that the "Always use cursor keys to navigate" box is not selected in the Advanced Options tab and made sure that the "Use autoscrolling" tab is selected. I tried uninstal

  • Updating JUST ONE topic in linked FrameMaker book

    I am trying to figure out exactly how the Update, Force Update, and Update All picks work in the TCS. It seems like everytime I make even a small change in a linked Frame doc, I slect Update to synch my help system and then end up losing all of the m

  • Can't burn Verbatim Archival grade DVDs

    Hi there! I own a Powermac G5 Dual 2.0 Ghz with Tiger updated and a Pioneer dvd recorder Mod. DVR-110D Firmware ver. 1.37. I can't burn Verbatim Archival grade DVD-R because I always get the following error code: 0x8002006E. It happens with Finder bu

  • NI Max Configurin​g Motion Bd Parameters - How to retrieve them

     I use my PXI-7344 Motion Card with Labview 7.1 and I configure the parameters such as the software limit thresholds in Ni Max.  When I am writing my Labview program and I am trying to see where the PXI-7344 SW Limits thresholds are set, I can not re