Chain problem: not being able to escape a bracket for a possible regular expression

So, I have barely any idea of how to use regular expressions except a little knowledge of it in PHP.

What I'm trying to do is to separate the first part of a string of qualifier, so I need a regular expression since ideally I wish I could. The problem I have is that my attempt of separation does not work. I tried to do what I think the model or class Matcher, I tried to use String.split, and I tried using the regular String.replace method. What I'm trying to do is illustrated (I hope) in the following NBS:
public class SSCCE
{
    public static void main(final String args[])
    {
        final String testString = "I want to keep this sentence. (I wish to "+
            "discard this sentence and the space in between the sentences.)";
        final String testExtract = testString.replace(" \(.+\)","");
        System.out.println(testExtract);
    }
}
From my understanding, the parentheses are supposed to be a wild card of sorts, so they would need to be escaped in order to be taken as a literal, which means that line 7 is supposed to correspond to any of the characters inside the brackets where the opening is preceded by a space and then delete them. The problem I have is that escaping brackets generates an error and does not escape their product the original string. So I don't know how to tell Java I use actually literal parentheses.

I tried to configure my preferences of error to ignore everything, but it does not work.

I don't know if it's important, but I use Java 1.6 and Eclipse for PHP 1.3.2.20110218 - 0812.

rp0428 wrote:
Shouldn't be using replaceAll if you use a regular expression?

http://docs.Oracle.com/javase/6/docs/API/Java/lang/string.html

and, on the assumption that you actually use a replaceAll(), you need to escape to the '-' characters as they are themselves i.e. Java escape characters

" \\(.+\\)"

In addition, the use of ".". +"can lead lead to important feedback. In this simple example you probably won't notice it, but in general, you'd better avoid the return back by using the reluctant modifier or by replacing the '.' by a character set that does not include the character terminal.

Tags: Java

Similar Questions

  • Code: 39 in Windows not being able to download a driver for CD/DVD... file is maybe missing or damaged

    Remove Arcsoft program, can I deleted some files that are shared by other Windows programs.  The tech who instaslled my new CD/DVD drive in my laptop Dell, Vista home Premium, all UPDATES in place, showed me the physical disk works fine.  However, an error message is displayed (in the title above) and Windows does not recognize the drive.  The technology suggested "Reinstall Windows" to "solve the problem.  I don't have the skills to do this.  Help?

    Discover - your CD or DVD cannot read or write media
    http://support.Microsoft.com/GP/cd_dvd_drive_problems

    and if so: http://support.microsoft.com/kb/982116

    TaurArian [MVP] 2005-2011 - Update Services

  • About a month ago I posted a question about iMovie and not being able to "share". I solved the problem thanks, so no more emails!

    About a month ago I posted a question about iMovie and not being able to "share". I solved the problem thanks, so no more emails!

    Hi Michael,

    If you want to stop receiving notifications by electronic mail, in the thread, that you have created, then I suggest that you follow the steps below:

    One time connected to the Apple Support communities, visit your mini profile and select manage subscriptions.

    Content

    To manage this content, you are currently subscribed and changing your preferences, select the content.

    Select next to see what content you are currently following.  Note that any thread you are responding you subscribe you automatically to this thread.

    You can select to terminate a subscription to a thread.

    Learn how to manage your subscriptions

    Take care.

  • problem of not being able to buy apps from the app store

    Dear Sir

    I was faced with a serious problem of not being able to buy apps from the app store after loading my $ 10 apple ID. Exactly the problem is that when I try to buy an application security qustion is requested and unfortunately I have forgtten the qustion of security. Also, I did not provide a recovery email of my apple ID and thus I can't find security qustion of appleid.apple.com. kindly could you help me to get the opportunity to purchase apps using my apple ID? Apple ID: * @yahoo.com password: * in advance sincerely yours Mehdi bajelan

    < personal information under the direction of the host >

    Click here > julien inconu Security Questions and answers - Apple ID and follow the instructions

  • How can I fix the problem of not being able to open files by double clicking with photoshop

    How can I fix the problem of not being able to open files with photoshop by double-clicking it in windows Explorer?

    This problem affects psd, jpg, and png files.  I get an error saying "the program can't start because adbeape.dll is missing on your computer.  I can open all these types of files in the menu 'open' in photoshop.  It is not a matter of them not having no not extensions.  I use windows 7.

    Thank you

    Thanks for the update.

    Just for test, could you please rename Photoshop.exe to Photoshop CC2015.exe location: C:\Program Files\Adobe\Adobe Photoshop CC2015

    then change the file association to the new renamed exe file and let us know if this helps or not.

  • SIRS; have not been able to access CC 2015 for all day; the little dotted wheel starts to turn. Is there a problem?  Thank you

    SIRS; have not been able to access CC 2015 for all day; the little dotted wheel begins to turn without opening... Is there a problem?

    Does not open App | Wheels of progress turn continuously

    https://helpx.Adobe.com/creative-cloud/KB/creative-cloud-app-doesn ' t - open.html

  • I'm in charge of a non-profit that uses Adobe Creative Suite 5. I have the software. but no product key. They want to have this facility on a new computer. I don't mean the software on the computer that works and not being able to get it insta on wreck

    I'm in charge of a non-profit that uses Adobe Creative Suite 5. I have the software. but no product key. They want to have this facility on a new computer. I wouldn't destroy the software on the computer that works and not being able to get installed it on the new computer. Help, please.

    Tony

    To reinstall the software, you will need the serial number. Please see this link:quickly find your serial number.

    Guinot

  • Not being able to create folders in the libraries

    Since few days back, I'm not be able to open new folders in my libraries (documents, pictures, etc..) Apparentlydo the "new folders" function is not ebnabled. I know not how to activate that or making sure is enabled or not. Can you help me? Thanks in advance for your answer. BTW, I am running Windows 7.

    Hello

    1. What is the brand and model of the computer?

    2. what security software is installed?

    3. don't you make changes to the computer before this problem?

    Let us try these methods.

    Method 1.

    Start the computer in safe mode and check if that helps.

    Advanced boot (including safe mode) options: http://windows.microsoft.com/en-US/windows7/Advanced-startup-options-including-safe-mode

    Method 2.

    Run a full scan of the computer with the Microsoft Safety Scanner to make sure that the computer is virus-free.

    Microsoft Safety Scanner: http://www.microsoft.com/security/scanner/en-us/default.aspx

    Security Scanner warning: there will be data loss through an analysis using the Microsoft safety scanner to eliminate viruses as appropriate.

    Let us know if you need assistance with any windows problem. We will be happy to help you.

  • Does anyone know what the cause some programs not being able to access the Internet? I had this problem with TurboTax and now with my Magic Jack.

    The TurboTax program told me that I was not connected to the Internet, even though I was and now my Majic Jack, who has worked 10 months told me the same thing.  I did nothing g to my computer except upgrades of Microsoft/Windows and I am at a loss as what to do.  Can anyone help?

    Hi CherieRadigan,

    1. are you able to connect to the internet successfully?

    2. facing a similar problem with other programs on the computer?

    3. What is the full error message that you receive?

    4. do you have security software installed on the computer?

    If you encounter a problem with internet connectivity to TurboTax and MagicJack program, then check out the links below to the Publisher of the software and check if it helps.

    MagicJack

    Error failed to configure magicJack / if please connect to the internet and double click here / Internet provider cannot be found. Make sure that you have an internet connection / unable to connect to the service provider

    TurboTax

    Connectivity errors

  • I am running Windows Vista Home Premium and I have this problem of not being able to recover Windows updates. I get error 80080005

    I tried to use the tips in a similar windows update error, but it does not give me the option to run as administrator when I right click on cmd

    See this previous & related discussion: http://social.answers.microsoft.com/Forums/en-US/vistawu/thread/29d7f9d1-56cd-42f3-bd44-7de8448ef70e

    Assuming that the Vista SP2 is not installed...

    Free unlimited installation and compatibility support is available for Windows Vista, but only for Service Pack 2 (SP2). This support for Windows Vista Service Pack 2 (SP2) is valid until November 26, 2009. Availability of support chat or messaging differs depending on your location. Go to http://support.microsoft.com/oas/default.aspx?prid=13014&gprid=582034 & select appropriate category (i.e., download problem;) Installation problem; Problems after installing a service pack).

    ~ Robear Dyer (PA bear); MS MVP (that is to say, mail, security, Windows & Update Services) since 2002. DISCLAIMER: I do not represent nor don't work for Microsoft

  • Problems with not being able to send and receive instant messages.

    I receive some messages, so cannot send or reveice messages.  The system seems to work and then stop.

    Hello

    (1) that you use any particular email Client or Webmail?

    (2) who is your email Service provider?

    (3) what version of IE are you using?

    (4) deal with the issue when using all other browsers like Google Chrome, Mozilla Firefox, Opera etc.?

    (5) you get an error message?

    You can try the following methods and check if it helps.

    Method 1: You can follow the steps mentioned in the link, troubleshooting

    Solve problems of access to webmail using Internet Explorer: http://support.Microsoft.com/kb/2483955

    Method 2: can't access some Web sites in Internet Explorer http://support.Microsoft.com/kb/967897
    Method 3: How to optimize Internet Explorer

    http://support.Microsoft.com/kb/936213/ro /

    WARNING: Reset Internet Explorer settings can reset security settings or privacy settings that you have added to the list of Trusted Sites. Reset the Internet Explorer settings can also reset parental control settings. We recommend that you note these sites before you use the reset Internet Explorer settings.

  • I have F.8 on both desktop and laptop, works perfectly on the laptop, but have problems with not being able to open some banking logon to desktop. Helped the popups for these sites.

    Also when closed with the button 'X', cannot re - opened up the app closes in the Task Manager. OK so firm using file - exit. However, a second icon is placed in Taslbar.

    Disabled CacheViewer continued and this seems to have solved all the problems.

  • Update for VISTA Business automatically leads to not being able to open the attachment in Windows Mail

    After an automatic update from Microsoft for VISTA Business on July 16, I now can't open attachments in the reading of e-mail messages in Windows Mail.  An error message indicates that the file is not found.  I have now to save all attachments and open my files before I read attachments.  It's very frustrating.  I had a similar experience, only a couple of weeks where a parameter is passed by an automatic update to VISTA leading to read all the emails being hidden from view.  I had never seen that before and it cost me £40 to get DELL Technical Support to sort for me.  Microsoft should not do this kind of thing are they?  Should I just revert to the original system (I have to pay DELL to do it for me) and just not allow Microsoft Update VISTA more.  I have my own business, no IT support and I want to just use my easy notebook for standard applications.  Nothing complicated.  I can't afford to waste time and money sorting on my laptop when I should run my own business in very difficult times.  Thanks to anyone who can advise me.

    I understand exactly what you're saying.

    Try this with updates to uninstall the problem and change the eo settings you decide what it is installed:

    Click Start > right click on computer > properties > Windows updates down the lower left corner > updates installed in the lower left corner in the next window

    > then click the one that you don't want > uninstall will appear at the top > uninstall it.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    In addition, on the page where you clicked "Installed updates", click on change settings at the top left corner it

    > Change update settings in the next page of AutoUpdate to "check for updates but let me choose etc" > OK ".

    When you take a look at pending updates, you can either download/install them one at the time, namely the update causing you problems.

    > or if you do not need an individual > right-click on > UAC prompt > hide it

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    And if you really need to go back to factory settings, save your self money.

    Dell recovery back to the means-to-do-it factory settings are listed below:

    Dell recovery options:

    http://supportapj.Dell.com/support/topics/global.aspx/support/DSN/en/document?journalid=67E9C215C4BABD6CE040AE0AB5E14F05&docid=339949

    It's way to Dell to reinstall from the DVD on your computer.

    Answer the questions in blue; It is in a sequence.

    http://supportapj.Dell.com/support/topics/global.aspx/support/DSN/en/document?journalid=67E9C215C4BABD6CE040AE0AB5E14F05&docid=336966

    And that way if you have a recovery partition on your hard drive.

    See you soon.

    Mick Murphy - Microsoft partner

  • IM NOT BEING ABLE TO PLAY A PC GAME

    I have correctly installed the Tomb Raider 2013 game for PC, but when I click on play, it turns out the info "failed to initialize Direct3D with current settings".

    What should I do to be able to play the game?

    Thanks to everyone who contributes with the comments here or in my email address: * email address is removed from the privacy *.

    ""failed to initialize Direct3D with current settings.

    Assuming that your machine has a proper graphics processor...

    (1) If you select exclusive fullscreen in the Launcher options you must also select Fullscreen.

    (Before you click Play by selecting Options in the start screen).

    (2) if the game does not always start you can find this deactivation

    In games Launcher can solve the problem there is a "full-screen exclusive" area by disabling the tick.

    (In this full screen game is actually a window without border - exclusive fullscreen is true full screen)

    (3) If you are unable to do without the Launcher to crash, you'll need solve the problem via the registry.

    -Press windows + R to bring up run and type in French - 'regedit '.

    -Navigate to ' HKEY_CURRENT_USER/Software/Crystal Dynamics/Tomb Raider'.

    -Create a subkey under Tomb Raider called "Graphics".

    In the graphs, you must create a DWORD value called "ExclusiveFullScreen" and set it to 0.

    (Must already be on 0).
    This will allow you will spend gambling.

    .

  • FBI scam and not being able to use the computer

    I used you tube yesterday evening to watch a video "elmo" for little girl, and this morning I got a screen that says FBI

    and I couldn't use computer until I paid 200.00 to green dot pre paid card.  I Googled it and said it was a scam

    and I could use the computer in safe mode, but I'm stuck now and don't know what to do.  I did a Norton scan and a

    free scan Microsoft security, and both show computer is fine, but I can't use the computer in normal mode.

    So what's up? What can I do?  Help! Please

    Hello

    1. excatly are you referring to when you say "tube"?
    2. What exactly happens in safe mode? When you say "stuck now" what error or problem you are facing?
    3. You are not able to start the computer in mde normal? What exactly happens when you try to start in normal mode?
    4. You receive an error message?
    5. What exactly is the problem you are having?

    If it works fine in safe mode, and then perform a clean boot.
    To help resolve the error and other messages, you can start Windows 7 by using a minimal set of drivers and startup programs. This type of boot is known as a "clean boot". A clean boot helps eliminate software conflicts.

    How to solve the problem by running the clean boot in Windows Vista and Windows 7:
    http://support.Microsoft.com/kb/929135
    Note: Once you have completed troubleshooting, perform step 7: to reset the computer as usual from the article mentioned above.

    I hope this helps!

Maybe you are looking for