String problem: Not being able to escape a parenthesis for a possible regex

So, I have barely any clue how to operate regular expressions except for a little bit of knowledge of it in PHP.
What I'm trying to do is to separate the first part of a string from a qualifier, so I need a regular expression since I would ideally like to be able . The problem I'm having is that my attempt at the separation isn't working. I've tried doing what I think the Pattern or Matcher class does, I've tried using String.split, and I've tried using the regular String.replace method. What I'm trying to do is illustrated (I hope) in the following SSCCE:
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, parentheses are supposed to be a wild card of sorts, so they would need to be escaped in order to be taken as literals, which means that line 7 is supposed to match any of the characters inside the parentheses when the opening one is preceeded by a space and then delete them. The problem I'm having is that escaping the parentheses produces an error, and not escaping them produces the original string. So I'm not sure how to tell Java that I'm actually using literal parentheses.
I already tried configuring my error preferences to ignore everything it could, but that didn't work.
I don't know if it matters, but I'm using Java 1.6 and Eclipse for PHP 1.3.2.20110218-0812.

ElectrifiedBrain wrote:
OK, that fixed it, but what would you recommend instead of ".+"? I don't know what a "reluctant modifier" is.The constructs ".+" and ".*" are 'greedy' in that they initially they capture as much as they can which fundamentally means that, depending on other options, they move forwards until the end of your string. If the regular expression is not satisfied at this point, backtracking is needed until the regex can never match or until a match is obtained. To overcome this one make the ".+" or ".*" reluctant to capture by use of a "?" i.e. ".+?" and ".*?" . Check the Javadoc for class java.util.regex.Pattern.

Similar Messages

  • How solve problem not being able to delete old autorisation Adobe Digital Editions at my laptop?

    Hello, I have bought a digital book but cannot open it with Adobe Digital Editions at my laptop. I did change my emailadress at my Adobe account to the same email adress as bol.com, where I bought the book. Bol.com told me to do so to be able to read the book at Adobe. The problem is that I cannot delete my old autorisation with my old emailadress in the Adobe Digital Editions programm. And therefore, I still cannot read the digital book I bought. Please can you give my support.

    What version of Digital Editions are you using?  When you say that you cannot delete your old authorization, what do you mean, exactly?  Are you getting an error?

  • Need help with Itunes problem not being able to put custom made ringtone on iphone 4s.

    My iphone 4s is running iOS7. My windows laptop is running the latest version of itunes, i follow instructions everywhere to get the ringtone i made onto my cellphone and i get stuck where it says to go to the apps tab and then scroll down till you see the apps you have and choose the app that you made the ringtone with. Well when i select apps it just goes to the app store, it doesn't do anything else. How in the world do i get that to come up so i can move the ringtone from the app to my phone??? please help!

    Although WAV files have the same audio coding as an audio CD, a disc full of WAV files does not act like an audio CD; it lacks the indexing and ToC needed in order for a "regular" CD player to play it. As Diane notes, put your WAV files in an iTunes playlist and burn it as an *audio CD.*

  • Problem not being able to click on photo album in nav bar when published

    Still a newbie I am trying to make an iweb site. Everything has gone well and after a week of playing around with it at nights this is my site: www.tinybulls.com. Nothing fancy but hopefully it will work for me.
    Everything is functioning well, I think (fingers crossed), except that the photo album button in the navigation bar is not clickable and i cannot get into that page when published. I use Safari if that info helps.
    Any ideas?
    Many thanks in advance!

    You created image files for each link and linked the box. A quick test would be do delete the current linked object and recreate it.
    If you link the text rather than the text box or object you can format the text's rollover and visited color. Also having text based links are more search engine friendly.
    OT

  • I'm at the end of my tether with not being able to access itunes which I could do perfectly well before! Now my laptop won't even connect to the internet despite the connection at the hub being excellent! No problem with ipad and phone - only windows!

    I'm tired of this problem of not being able to access itunes on my laptop and now no internet access despite connection and strength being excellent. What are windows playing at? Worked perfectly well until recently. Very frustrating and time consuming!

    Just a few lines to assure you you are not alone regarding speed delivery. By no means.
    I'm on Infinity 2 with HH5 - was virtually guaranteed 63 d/l and told possibly even up to 78. My actual speeds are nearer 15 (yes 15!) to 28 d/l if I am lucky. I've played all the obligatory games of checking and posting and reviewing my HH stats - and of course wasting my time with India "help" customer services who are instructed to read from a script of inane generalities which are usually completely irrelevant and have no connection whatsoever with a user's Specific problem.
    It more often than not turns out that the automated monitoring system imposes a software called DLM = Digital Line Management = which (with the endless excuse of improving line stability) increases noise margins and drastically reduces speed. This can kick in pretty rapidly and can take at least 3 to 4 days to modify itself - if indeed at all!!! Usually an Openreach engineer visit is then needed - who will re-set the Profile to what it is you are supposed to be paying for ..... then of course it is totally possible that DLM will re-emerge and the same old cycle of troubles will have to be endured.
    We pay in good faith at the outset on the back of so many promises - only to be cynically let down and dismissed once signed up. It is quite wrong we have to continually argue our case to (try) to get anywhere and are always reminded that we are tied into contracts with expensive escape clauses - or that an engineer's visit is only free IF it is proved the fault is not inside your house - which it very rarely is! This is often more an Ordeal than a subscribed service. Superfast reliable Broadband in the UK ? Ha!

  • TS1702 Does anyone know how to resolve the problem of apps not being able to download in the App Store? After the IOS 6 update I haven't been able to download any apps.

    Does anyone know how to resolve the problem of apps not being able to download in the App Store? After the IOS 6 update I haven't been able to download any apps.

    Maybe here:
    IOS 6 App store crash: Apple Support Communities

  • HT201210 In the attempt of updating the latest itune software, i am faced with the problem of not being able to be connected to itunes with my ipod touch that is blocked living the USB cable and the itune icons on my touch sceen. Can some one help me out

    In the attempt of updating my ipod touch, i am  faced with the problem of not being able to be connected to the itunes in my computer (windows xp ) because my ipod touch got blocked up, leaving the icon of USB cable and itunes on my touch screen. I am asked to restore my ipod first, but i have tried using all the examples stated and still can't help. Please please, can some one help me out ? Ones  in the process of trying, i see an error code: 1656 and most of the time nothing. Thanks

    See if placing the iPod in Recovery mode will allow a restore via iTunes
    Next try DFU mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    You can also try another computer to help determine if you have a computer or iPod problem.

  • TS4040 I assumed this would help my problem with not being able to open apps like Preview or TextEdit since I installed Mountain Lion. Instead, first I'm prompted to enter a password, then once I do that, I get an error box telling me the Library needs re

    I assumed this would help my problem with not being able to open apps like Preview or TextEdit since I installed Mountain Lion. Instead, first I'm prompted to enter a password, then once I do that, I get an error box telling me the Library needs repairing. So I click on Repair, and once again I'm prompted for a password, which I enter, then the same error box opens, and so it goes. Can anyone help me with this problem? I'd greatly appreciate it.
    Thor

    Back up all data. Don't continue unless you're sure you can restore from a backup, even if you're unable to log in.
    This procedure will unlock all your user files (not system files) and reset their ownership and access-control lists to the default. If you've set special values for those attributes on any of your files, they will be reverted. In that case, either stop here, or be prepared to recreate the settings if necessary. Do so only after verifying that those settings didn't cause the problem. If none of this is meaningful to you, you don't need to worry about it.
    Step 1
    If you have more than one user account, and the one in question is not an administrator account, then temporarily promote it to administrator status in the Users & Groups preference pane. To do that, unlock the preference pane using the credentials of an administrator, check the box marked Allow user to administer this computer, then reboot. You can demote the problem account back to standard status when this step has been completed.
    Triple-click the following line to select it. Copy the selected text to the Clipboard (command-C):
    { sudo chflags -R nouchg,nouappnd ~ $TMPDIR.. ; sudo chown -Rh $UID:staff ~ $_ ; sudo chmod -R u+rwX ~ $_ ; chmod -R -N ~ $_ ; } 2> /dev/null
    Paste into the Terminal window (command-V). You'll be prompted for your login password, which won't be displayed when you type it. You may get a one-time warning to be careful. If you don’t have a login password, you’ll need to set one before you can run the command. If you see a message that your username "is not in the sudoers file," then you're not logged in as an administrator.
    The command will take a noticeable amount of time to run. Wait for a new line ending in a dollar sign (“$”) to appear, then quit Terminal.
    Step 2 (optional)
    Step 1 should give you usable permissions in your home folder. This step will restore special attributes set by OS X on some user folders to protect them from unintended deletion or renaming. You can skip this step if you don't consider that protection to be necessary, and if everything is working as expected after step 1.
    Boot into Recovery by holding down the key combination command-R at startup. Release the keys when you see a gray screen with a spinning dial.
    When the OS X Utilities screen appears, select
    Utilities ▹ Terminal
    from the menu bar. A Terminal window will open.
    In the Terminal window, type this:
    res
    Press the tab key. The partial command you typed will automatically be completed to this:
    resetpassword
    Press return. A Reset Password window will open. You’re not  going to reset a password.
    Select your boot volume ("Macintosh HD," unless you gave it a different name) if not already selected.
    Select your username from the menu labeled Select the user account if not already selected.
    Under Reset Home Directory Permissions and ACLs, click the Reset button.
    Select
     ▹ Restart
    from the menu bar.

  • Problem with Adobe Reader not being able to run with Maverick  10.9.2?

    problem with Adobe Reader not being able to run with Maverick  10.9.2?

    Have you updated your version of Adobe Reader?

  • Who else has a problem with parental controls enabled not being able to run Firefox on the Mac?

    Who else has a problem with parental controls enabled not being able to run Firefox on the Mac? (Any solutions?) (BTW. Chrome doesn't work either)

    Although FF4 is so nice I'm almost ready to ditch iGoogle!
    Please fix what appears to be an RSS/iGoogle issue with FF4...
    Gmail is fine, but titles dont show in most RSS feed gadgets and no stories, strangely, apart from this one:
    http://www.google.com.au/ig/directory?hl=en&url=www.google.com/ig/modules/builtin_news_technology.xml
    Which if you enter the last part of the url reports that
    "<Content type="html">
    This is a builtin module, so the UserPrefs and Content are ignored."
    Any ideas?

  • Have not being able to download due to billing problem,this just unfair

    Have not being able to download due to billing problem,this just unfair

    FOR ASSISTANCE WITH ORDERS - iTUNES STORE CUSTOMER SERVICE
    For assistance with billing questions or other order inquiries, please refer to our online support page by clicking here: http://www.apple.com/support/itunes/store/. If you cannot find the answers you are seeking in our robust knowledge base, you can contact us by visiting the following URL http://www.apple.com/support/itunes/store/, clicking on the appropriate Customer Service topic, then using the contact button or email form at the bottom of the page. Responses to emails will be provided as soon as possible.
    Phone: 800-275-2273 How to reach a live person: Press 0 four times
    Hours of Operation: Mon-Fri: 9am-5pm ET
    Email: [email protected]
    How to report an issue with Your iTunes Store purchase
    http://support.apple.com/kb/HT1933
    iTunes Purchase Problems: How to Report a Problem to iTunes Support
    http://tinyurl.com/7tscpa7
    How to Get a Refund from the App Store
    http://gizmodo.com/5886683/how-to-get-a-refund-from-the-app-store
    Getting Refunds for your iTunes Store Purchases
    http://www.labnol.org/software/itunes-app-store-refunds/13838/
    Canceling a Digital Subscription
    http://gadgetwise.blogs.nytimes.com/2011/10/14/qa-canceling-a-digital-subscripti on/
     Cheers, Tom

  • I am not being able to create my apple ID as my card details are not being accepted by the app store. i tried with my visa card as well as master card. help me out to solve the problem..

    I am not being able to create my apple ID as my card details are not being accepted by the app store. i tried with my visa card as well as master card. help me out to solve the problem..

    Were the VISA and MasterCard issued to you by a bank in the country where you reside and do they have a verifiable billing address in the same country?
    Or are these debit cards that you bought in a local store. Apple does not accept debit cards that you bought.

  • How do I tell Apple to fix their software like apps that play sound even though the sound is turned off and not being able to disable features you hate like game center

    Apple is suppose to be the pinnacle of usability and, yet, I want to throw my new IPhone 4s as far as I can and watch is smash into a million pieces on concrete. Seriously, I've already got three things that irritate the **** out of me. First, there are Apple apps that insist on playing sound even though the sound is turned off. If I flick a switch to turn the sound off, I want the sound off!!!! Second, if I do not want a totally unnecessary feature like Game Center, I should be able to disable it. I completed most of the Angry Bird levels with 2 or 3 stars and now I have to start over from square one. Maybe, this happened when I upgraded to the 4s but it sure seemed to happen when I joined Game Center. Tomorrow, I am going to reset my 4s to factory defaults to try to get rid of my Game Center account. I don't want Game Center! I do need Game Center! I hate Game Center! Finally, I had an alarm go off to wake me up and there was a Snooze button but no button to turn the alarm off. I flicked the slider to access the main screen expecting to see something to turn the alarm off but there was nothing. The alarm just kept alarming. I had to warm boot my IPhone to shut the alarm off! Really, Apple!!!!

    The sound is turned off. Only, some Apple apps like YouTube and Siri make sound when the sound is turned off. It is very embarrassing when this happens at work. My question was how do I tell Apple to fix this?
    Turning off game center does not work. The games just prompt me to sign in when they are started.I have tried everything I can find online to stop this behavior. It is annoying and should not happen. My question was how do I tell Apple to fix this?
    The alarm went off. There was a green thing that looked like a button but pressing it did nothing. There was a red button that said snooze. I did not want to snooze. I wanted to turn the alarm off. I slid the bar to unlock the phone and there were no running apps with a button to press. The alarm just keep running. I have not had this problem since it first occurred. The alarm now shuts off when I just unlock the phone. It may have happened because I had another alarm app running. The two may have interfered with each other. I would like to tell Apple about it.
    It also annoys me that the button that closes apps leaves the phone app running. If I press on a number at 6:00 AM to get information about who called me, the phone automatically dials the person back and my natural reaction is to press on the button to close the phone app but the phone keeps dialing this person at 6:00 AM. It is a bad design. I would like to tell Apple about it.
    Finally, I looked all over Apple's site to try to find someplace I could send them a polite message to let them know that I was not happy with these "features" but could not find anything. It is extremely frustrating to have issues with a product and not being able to tell the manufacturer about it. So, you grow up!.
    When trying to fix the Game Center issue, I saw a link someone posted to report issues with the IPad to Apple. The answer I am looking for is where is the link to report issues with the IPhone.

  • I can't play any purchased movies. Sounds like it is the 6.0 update. So what is the fix? Am I just stuck not being able to use my Apple TV until...?

    I can't play any purchased movies. Sounds like it is the 6.0 update. So what is the fix? Am I just stuck not being able to use my Apple TV until...?

    Sorry I can't help but I have potentially a similar problem.
    We have an Apple TV 3 and after the most recent software update (potentially coincidental timing), our purchased movies & TV shows will no longer play for our US account. We can play previews but that's it. We also tried renting a new movie but that didn't work either. No error messsage, just select play, it thinks about it, then returns you to the same screen again.
    Any help greatly appreciated.
    Thanks

  • I downloaded the Beta 4 version tried to leave feedback and it says I need to download the beta version, what is going on? I want to leave feed back on NOT being able to download pics in hotmail with the new beta version????

    I want to download a picture from my hotmail email, but it keeps reverting back to the email pic. Wont download it. I had to go to my Yahoo account to do this! When I went to the feedback for the New beta version FireFox 4 I was told I had to install the beta version - WHICH I already have! HELP
    == This happened ==
    Every time Firefox opened
    == I downloaded the Beta version FireFox 4

    The version I am using is 4.0 - I went and Reset user agent to everything showing on the link sent:
    general.useragent.extra.firefox;Firefox/4.0b1
    general.useragent.locale;en-US
    general.useragent.security;U
    I am still unable to download pics in hotmail..... Along with not being able to use Aviary Image Editor as it says it is Not compatible with the 4.0 version. So that Add-on picked up the right version I am using. (I use this to take ScreenShots!) - I sure hope this will be available when FireFox 4.0 is fully launched.....................
    Along with the email pic problem :(
    Thanks for the help

Maybe you are looking for

  • TS1398 No longer able to access Wi-Fi!

    Since the 5.1.1 update I can no longer connect to Wi-Fi. My phone can not even find any Wi-Fi signal at all! I know this is a software problem because my wife does not have the update and she can access our Wi-Fi. What do i do?

  • What is the best configuration for XP on a MacPro?

    Situation: Macpro (the old one) 3 hardrives; 1st is the Mac OSX HD 2nd Windows XP 3rd Extra Data this is how my setup is, but i notice my computer makes a louder noise as before, why is this? would you recommend this setup or install XP on the same d

  • Powerbook 12'' Maximum HD?

    I am going to buy a 12'' Powerbook on eBay and it comes with an 80gig HD. This is not enough for me and was wondering if it could be fit with a 200 or even 250gig HD or is there a limit? Thanks.

  • How do I Nudge clips in the timeline

    Hello All, I relatively new to Pr Pro and I am working on a music Video.  I need to sync various clips to the music track.  I would like to know is there a key command for nudging clip position in the timeline so that I can more easily get my mouth m

  • Is there a way to disable OIM entity adapters while doing batch upload ?

    Hi experts, I have an adpater to generate UserID from a sequence based on user-type for creation of OIM users thru web UI. I have attached this to Users form in data object manager. We also have a 3-step batch bulk procedure from CSV file which check