Java Regex, how do I replace \\ with \\\\?

Hello,
The following line doesn't work: someString.replaceAll("\\", "\\\\");
The error I get is the following:
Exception in thread "main" java.util.regex.PatternSyntaxException: Unexpected internal error near index 1
^
     at java.util.regex.Pattern.error(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 TSPEngine.main(TSPEngine.java:34)
How do I fix this?
Thanks in advance,

Interference wrote:
Hello,
The following line doesn't work: someString.replaceAll("\\", "\\\\");
The error I get is the following:
Exception in thread "main" java.util.regex.PatternSyntaxException: Unexpected internal error near index 1"\\" is how you represent "\" in a String literal in Java, since "\" is an escape character. But "\" is also an escape character in regular expressions, meaning to represent a literal "\" in a Java regex you need "\\\\". Your second string should be fine since it's not interpreted as a regular expression to my knowledge.
Edit:
No, the second string DOES need to be "\\\\\\\\".
Edited by: endasil on 17-May-2010 11:46 AM

Similar Messages

  • After I installed ios7, I entered the wrong Apple ID. How do I replace with the correct ID?

    After I installed ios7, I entered the wrong Apple ID. How do I replace with the correct ID?

    OK, so all you need to do is:
    Go into Settings>iTunes, tap on the Apple ID and then tap on Sign Out. Then sign back in with your new Apple ID.
    Go to Settings>iCloud, scroll to the bottom and tap on Delete Account (it will ask you for a password). Try typing in the password that you think goes with that Apple ID. If that doesn't work, try your current Apple ID password. If that doesn't work, go into Manange your Apple ID and sign on with the old Apple ID and reset the password:  https://appleid.apple.com/cgi-bin/WebObjects/MyAppleId.woa/
    Once you have deleted the old iCloud account, you can then go to Settings>iCloud and sign on with your current Apple ID.
    Cheers,
    GB

  • Hi I have iPhone 4 crack screen how much to replacement with anther one from apple store ?

    Hi I have iPhone 4 crack screen how much to replacement with anther one from apple store ?

    If your iPod Touch, iPhone, or iPad is Broken
    Apple does not fix iDevices. Instead, they exchange yours for a refurbished or new replacement depending upon the age of your device and refurbished inventories. On rare occasions when there are no longer refurbished units for your older model, they may replace it with the next newer model.
    ATTN: Beginning July 2013 Apple Stores are now equipped to do screen repairs/replacements in-house. In some cases while you wait. According to Apple this is the beginning of equipping Apple Stores with the resources needed to do most repairs for iPhones, iPads, and iPod Touches that would not require major replacements. Later in the year the services may be extended as Apple Stores become equipped and staffed with the proper repair expertise. So, if you need a screen repaired or a broken screen replaced or have your stuck Home button fixed, call your local Apple Store to see if they are now doing these in-house.
    You may take your device to an Apple retailer for help or you may call Customer Service and arrange to send your device to Apple:
    Apple Store Customer Service at 1-800-676-2775 or visit online Help for more information.
    To contact product and tech support: Contacting Apple for support and service - this includes international calling numbers.
    iPod Service Support and Costs
    iPhone Service Support and Costs
    iPad Service Support and Costs
    There are third-party firms that do repairs on iDevices, and there are places where you can order parts to DIY if you feel up to the task. Start with Google to search for these.

  • Replacement of iPad-3 to iPad-4? I want to know more about policy within 14 days the date of purchase,how can i replace with the ipad4? ?

    Hi
    I want to know the policy of replacement under 14 days of purchase iPad-3. I bought ipad-3 3 days ago before the launch of iPad-4. I want to know more about 14 days policy. I bought my iPad-3 not from the apple store , but it was the authorized apple center. If they are not the part of you so why you giving the license to sell your product. Is this not a cheating? We are purchasing Apple product. We have trust on Aplle thats why we purchase from them.
    I bought Apple's iPad-3 not samsung or nokia iPad-3 so Apple is responsible not ANYONE. Because Apple dint announce anything before neither they cut off their prices on iPad-3.
    Now my point is this i want to know more about 14 days exchange policy who bought their ipad-3 within 14 days from the dealers.
    Now I want to replace my iPad-3 with iPad-4 because i bought just 3 days before new one is Launch.Same price less Technology 3 days before woowwwwww....
    New CEO Tim Cook is taking gr8 step for its loyal customers. Tim are you working with samsung now? How much money they pay you to destroy Apple?

    I have rang my local apple store this morning and they have told me that they will swap out the ipad 3 to the ipad 4. I have the 4G version and im in the uk im sure that this may be the reason why they will for me due to 4g networks in uk not being compatible with the ipad 3..
    Just ring your local store they will im sure help you with all the info

  • 'CONDUIT' seems to have envagled its way and istalled itseldf as the search engine of choice from Firefox log in. How do i replace with GOOGLE .. please

    When I open firefox at the start of a session the search engine 'CONDUIT' fires up.
    I don't understand how this outfit has imposed itself on my system ... unless it's all part of a firefox utility upgrade?
    If it is and I can't replace Conduit with Google UK ... then I'll move elsewhere.
    Can you advise whether this is a 'Firefox' preferred package and if I have thee option to remove it / replace it with Google ... and if, then How ???

    Try to reset your keyword,url settings, see:
    * https://support.mozilla.com/en-US/kb/Location%20bar%20search#w_domain-guessing
    instruction are locate at top of domain guessing section

  • My 4s is now out of contract but very cracked how much to replace in Perth Australia?

    How much to replace with new/refurbished 4s in perth Australia?

    You can look this up yourself:
    http://www.apple.com/support/service/

  • Search given string array and replace with another string array using Regex

    Hi All,
    I want to search the given string array and replace with another string array using regex in java
    for example,
    String news = "If you wish to search for any of these characters, they must be preceded by the character to be interpreted"
    String fromValue[] = {"you", "search", "for", "any"}
    String toValue[] = {"me", "dont search", "never", "trip"}
    so the string "you" needs to be converted to "me" i.e you --> me. Similarly
    you --> me
    search --> don't search
    for --> never
    any --> trip
    I want a SINGLE Regular Expression with search and replaces and returns a SINGLE String after replacing all.
    I don't like to iterate one by one and applying regex for each from and to value. Instead i want to iterate the array and form a SINGLE Regulare expression and use to replace the contents of the Entire String.
    One Single regular expression which matches the pattern and solve the issue.
    the output should be as:
    If me wish to don't search never trip etc...,
    Please help me to resolve this.
    Thanks In Advance,
    Kathir

    As stated, no, it can't be done. But that doesn't mean you have to make a separate pass over the input for each word you want to replace. You can employ a regex that matches any word, then use the lower-level Matcher methods to replace the word or not depending on what was matched. Here's an example: import java.util.*;
    import java.util.regex.*;
    public class Test
      static final List<String> oldWords =
          Arrays.asList("you", "search", "for", "any");
      static final List<String> newWords =
          Arrays.asList("me", "dont search", "never", "trip");
      public static void main(String[] args) throws Exception
        String str = "If you wish to search for any of these characters, "
            + "they must be preceded by the character to be interpreted";
        System.out.println(doReplace(str));
      public static String doReplace(String str)
        Pattern p = Pattern.compile("\\b\\w+\\b");
        Matcher m = p.matcher(str);
        StringBuffer sb = new StringBuffer();
        while (m.find())
          int pos = oldWords.indexOf(m.group());
          if (pos > -1)
            m.appendReplacement(sb, "");
            sb.append(newWords.get(pos));
        m.appendTail(sb);
        return sb.toString();
    } This is just a demonstration of the technique; a real-world solution would require a more complicated regex, and I would probably use a Map instead of the two Lists (or arrays).

  • How do I replace someone else's Mac ID with my own? Bought iPhone second hand. Previous owner re-set the phone but his ICloud account stayed on now my phone. He uses his macID on his new iPhone now?? Any ideas, as this issue is blocking my access to iTune

    How do I replace someone else's Mac ID with my own?
    Bought iPhone second hand on TradeMe.
    Previous owner re-set the phone but his ICloud account stayed on now my phone. He uses his AppleID on his new iPhone now and, understandably, does not want to give me his password. Any ideas?? Please.
    This issue is blocking my access to iTunes and any other file from my home computer. It keeps on telling me that I have to autorise my computer to pass on files, yet, it seems, for all this to happen, I need to get logged in through the phone's Apple ID. This of course is different to my one on my computer - and I have no password for it.
    This phone is not stolen!! I payed still a fair bit for it. Am still in contact with the previous owner. He doesn't know how to fix the problem either.
    Would appreciate any suggestion ????
    Thanks
    SamSings

    Settings>general>resets>erase all content and settings.
    That will put it back to its out of the box state. Set it up with your own apple Id.

  • HT4436 I have now downloaded all of my CD's to my itunes library and have since only purchased new music using itunes Store.  This itunes library is stored on an old Dell Desktop that I am getting ready to replace with an iMac; how can I move the music? 8

    I have now downloaded all of my CD's to my itunes library and have since only purchased new music using itunes Store.  This itunes library is stored on an old Dell Desktop that I am getting ready to replace with an iMac; how can I move the music? 86GB
    Is the music I downloaded from my CD's already in the iCloud or only the music I purchased on itunes?

    This might help: http://www.macworld.com/article/1146958/move_itunes_windows_mac.html.

  • Has anyone experienced problems with Mackeeper? I did not complete downloading this software. Yet, occasionally when on the internet, I will have the MacKeeper multi-colored circle replace my pointer. How do you deal with this?

    Has anyone experienced problems with Mackeeper? I did not complete downloading this software. Yet, occasionally when on the internet, I will have the MacKeeper multi-colored circle replace my pointer. How do you deal with this?

    Welcome to Apple Support Communities
    Don't download MacKeeper. Users complain about this app and it damages OS X. Also, Mac OS X knows how to take care of itself, so you don't need any other cleaning application that may damage OS X. See > https://discussions.apple.com/docs/DOC-3691

  • I have a power pc (g5) computer that I will soon be replacing with a current i5 or i7 mini. How do I transfer the Time Machine files from the internal hard drive on the G5 to an external drive that I will later use with the Mini?

    I have a Power PC G5 computer that I will soon be replacing with a current i5 or i7 Mini. How do I transfer the Time Machine files from the internal hard drive on the G5 to an external drive that I will later use with the Mini?

    Hi, likely the easiest is to just poll the drive & get something like this...
    Get MacScan...
    http://www.apple.com/downloads/macosx/networking_security/macscan.html
    http://eshop.macsales.com/item/NewerTech/U3NVSPATA/
    But if you have a good external drive already, just clone it.
    Get carbon copy cloner to make an exact copy of your old HD to the New one...
    http://www.bombich.com/software/ccc.html
    Or SuperDuper...
    http://www.shirt-pocket.com/SuperDuper/

  • How do i replace a newer version of itunes with an older version of itunes

    how do I replace a newer version of iTunes with an older version?

    go to help then check for updates should show up then click on that an it should work

  • How can I replace my old print driver with my new printer driver on 13

    how can I replace my old print driver with my new print driver on photo elements 13

    The print driver is not installed in PSE.
    Check with the manufacturer of your printer.

  • My iPhone 5 has broken and is being replaced with a new iPhone tomorrow. However, My carrier (orange) will b picking up my broken iPhone and I am unsure how to secure the content and icloud data on the broken phone. Is there a way to display the data?

    My iPhone 5 has broken and is being replaced with a new iPhone tomorrow. However, My carrier (orange) will b picking up my broken iPhone and I am unsure how to secure the content and icloud data on the broken phone. Is there a way to disable the data held on it and ensure that if it is fixed, nobody can use/see my data and access my account?

    Hi Gazpan,
    Thanks for visiting Apple Support Communities.
    I recommend using the steps in this article to back up your iPhone if possible:
    iOS: Back up and restore your iOS device with iCloud or iTunes
    http://support.apple.com/kb/ht1766
    You may also find this advice helpful for your situation:
    What to do before selling or giving away your iPhone, iPad, or iPod touch
    http://support.apple.com/kb/ht5661
    If you no longer have your iOS device
    If you're using iCloud and Find My iPhone on the device, you can erase the device remotely and remove it from your account by signing in to icloud.com/find, selecting the device, and clicking Erase. When the device has been erased, click Remove from Account.
    If you're unable to complete either of the above steps, you should change your Apple ID password. Changing your password won't remove any personal information that is cached on the device, but it will make sure that the new owner can't delete your information from iCloud.
    Cheers,
    Jeremy

  • How Can I replace newScale Text Strings with Custom Values?

    How Can I replace newScale Text Strings with Custom Values?
    How can I replace newScale text strings with custom values?
    All  newScale text is customizable. Follow the procedure below to change the  value of any text string that appears in RequestCenter online pages.
    Procedure
    1. Find out the String ID of the text string you would like to overwrite by turning on the String ID display:
    a) Navigate to the RequestCenter.ear/config directory.
    b) Open the newscale.properties file and add the following name-value pair at the end of the file:res.format=2
    c) Save the file.
    d) Repeat steps b and c for the RmiConfig.prop and RequestCenter.prop files.
    e) Stop and restart the RequestCenter service.
    f) Log  in to RequestCenter and browse to the page that has the text you want  to overwrite. In front of the text you will now see the String ID.
    g) Note down the String ID's you want to change.
    2. Navigate to the directory: /RequestCenter.ear/RequestCenter.war/WEB-INF/classes/com/newscale/bfw.
    3. Create the following sub-directory: res/resources
    4. Create the following empty text files in the directory you just created:
    RequestCenter_0.properties
    RequestCenter_1.properties
    RequestCenter_2.properties
    RequestCenter_3.properties
    RequestCenter_4.properties
    RequestCenter_5.properties
    RequestCenter_6.properties
    RequestCenter_7.properties
    5. Add the custom text strings to the appropriate  RequestCenter_<Number>.properties file in the following manner  (name-value pair) StringID=YourCustomTextString
    Example: The StringID for "Available Work" in ServiceManager is 699.
    If you wanted to change "Available Work" to "General Inbox", you  would add the following line to the RequestCenter_0.properties file
         699=General Inbox
    Strings are divided into the following files, based on their numeric ID:
    Strings are divided into the following files, based on their numeric ID:
    String ID  File Name
    0 to 999 -> RequestCenter_0.properties
    1000 to 1999 -> RequestCenter_1.properties
    2000 to 2999 -> RequestCenter_2.properties
    3000 to 3999 -> RequestCenter_3.properties
    4000 to 4999 -> RequestCenter_4.properties
    5000 to 5999 -> RequestCenter_5.properties
    6000 to 6999 -> RequestCenter_6.properties
    7000 to 7999 -> RequestCenter_7.properties
    6. Turn off the String ID display by removing (or commenting out) the line "res.format=2" from the newscale.properties, RequestCenter.prop and RmiConfig.prop files
    7. Restart RequestCenter.
    Your customized text should be displayed.

    I've recently come across this information and it was very helpful in changing some of the inline text.
    However, one place that seemed out of reach with this method was the three main buttons on an "Order" page.  Specifically the "Add & Review Order" button was confusing some of our users.
    Through the use of JavaScript we were able to modify the label of this button.  We placed JS in the footer.html file that changes the value of the butt

Maybe you are looking for

  • How to handle "/9.2.0/root.sh as root from another window" in silent instal

    Hi, I was successful to start a silent installation of Oracle9iR2 using a responsefile on my System RHEL 3. But the installation ends soon and a wrong successful install message: Error :*** Alert: A configuration script needs to be run as root before

  • Help needed in script

    Hi All... We have one custom form and driver program. Now i need to copy those two with diffrent names and i need to make some changes in that. What my problem is.. after making the changes we created an output type and we attached the form name and

  • Oracle to connect MySQL

    Dear All, from couple of days I am trying to connect mysql from my oracle database. I have studied so many documentations and have created one of my own. I am just struck at one point. My oracle database is 11gR1 and CentOS 5.1 32-bit is the operatin

  • Games for macbook pro

    Can you get games such as solitaire, hearts, etc for macbook pro for free?  I just want the basics...

  • Trying to use signal in and signal out but couldn't pass parameters

    Hi all,            I am trying to use Signal out from 1st iview and trying to get the same parameters to the second iview where this iview gets populated when i click a button in result of first iview. I have created these two iviews in same model an