I want to replace "\" with "/" in a string.

I tried this...
String whatever = myString.replace("\\", "/");
...and this...
String whatever = myString.replace("\", "/");
...but I get an error.
I was able to get it to work doing it this way...
String slashStr = "\\/";
char slashArr[] = slashStr.toCharArray();
whatever = whatever.replace(slashArr[0], slashArr[1]);
But I think that is silly.
Can someone tell me why the first method won't work?

String whatever = myString.replace("\\", "/");
String.replace
...and this...
String whatever = myString.replace("\", "/");
...but I get an error.This is correct. There is no method String.replace(String,String)
only String.replace(char,char)
I was able to get it to work doing it this way...
String slashStr = "\\/";
char slashArr[] = slashStr.toCharArray();
whatever = whatever.replace(slashArr[0], slashArr[1]);
But I think that is silly.It is a bit.
String s1 = "This\\Is\\The\\Original";
String s2 = s1.replace('\\','/');
...Or something like that... Single quotes indicate a char literal
- double-quotes indicate a string literal.
Talden

Similar Messages

  • Windows 2k server i want to replace with a mac mini running server

    have a windows 2k server i want to replace with a mac mini running server 10.4.7
    i basically want to port the settings and accounts from the 2 k running crap entourage to mac mail or keiro .
    does anyone have a good way to do this or know of resources
    i want all the accounts to stay active and will set up the same setting for the mini to runt he same services the old 2 k box was doing .
    just some file sharing and mail services .
    thanks
      Mac OS X (10.4.8)  

    Look just to the right at "More Like This"
    You might also check at > Korg Support

  • Replace " with ' in a string

    I need to replace " with '.
    Does any have a solution? The follwing code has a problem to define
    sString replace =""";
    public String replace(String str, String pattern, String replace) {
    int s = 0;
    int e = 0;
    StringBuffer result = new StringBuffer();
    while ((e = str.indexOf(pattern, s)) >= 0) {
    result.append(str.substring(s, e));
    result.append(replace);
    s = e+pattern.length();
    result.append(str.substring(s));
    return result.toString();
    Thanks.
    Jian

    use "\"" instead

  • To replace "\" with "/" in a string using FrameMaker API

    How to replace "\folder1\folder2\folder3" with "folder1/folder2/folder3" using framemaker API ?

    Hi Asha,
    Here is a function that I use for substring replacement, using all FDK library functions. If you use standard C libraries instead, you could probably reduce this to a line or two.
    To use it, you would send something like:
    path = F_StrCopyString("\\folder1\\folder2\\folder3");
    strReplace(path, "\\", "/", False);
    There might be better ways to do this. I'm not really that much of a programmer.
    Russ
    //returns the index of the first change, or -1 if no changes.
    IntT ws_StrReplace(StringT *mainString,
                       StringT searchString,
                       StringT replaceString,
                       IntT considerCase)
      StringT strBuf,
        returnString,
        appendString;
      IntT i,
        firstIndex = -1;
      //if the search string is empty, there is nothing to do.
      if(F_StrIsEmpty(searchString))
        returnString = F_StrCopyString(*mainString);
      else
        //otherwise, initialize the buffer
        returnString = F_StrCopyString("");
        for(i = 0; i < F_StrLen(*mainString); i++)
          strBuf = F_StrCopyString(*mainString);
          //Truncate the string from the beginning
          F_StrReverse(strBuf, 10000);
          F_StrTrunc(strBuf, (F_StrLen(strBuf) - i));
          F_StrReverse(strBuf, 10000);
          //and lop it down to the size of the search string
          if(F_StrLen(strBuf) > F_StrLen(searchString))
            F_StrTrunc(strBuf, F_StrLen(searchString));
          //if they are the same, we are doing the replacement
          if((considerCase && F_StrCmp(strBuf, searchString) == 0) ||
             (!considerCase && F_StrICmp(strBuf, searchString) == 0))
            appendString = F_StrCopyString(replaceString);
            //set the return value
            if(firstIndex < 0) firstIndex = i;
            //jimmy the loop so we step past the length of the replacement
            //string the next time around
            i += F_StrLen(searchString) - 1;
          //otherwise, we are just appending 1 character on.
          else
            F_StrTrunc(strBuf, 1);
            appendString = F_ApiCopyString(strBuf);
          //now, concatenate
          //rciReturnString = F_Realloc(rciReturnString,
            //F_StrLen(rciReturnString) + F_StrLen(rciAppendString), NO_DSE);
           returnString = (StringT) F_Realloc(returnString,
            (F_StrLen(returnString) + F_StrLen(appendString))*sizeof(StringT), NO_DSE);
          F_StrCat(returnString, appendString);
          F_ApiDeallocateString(&strBuf);
          F_ApiDeallocateString(&appendString);
        } //end main else
      //all done
      F_ApiDeallocateString(mainString);
      *mainString = F_StrCopyString(returnString);
      F_ApiDeallocateString(&returnString);
      return firstIndex;

  • IPhoto 8.1.2 - want to replace with iPhoto '11 but App Store says Installed

    I have a MacPro at home and a MBP which I also use - I have the 'old' iLife 09 which provided iPhoto in ver. 8 form [updaed to 8.1.2 in 2010] - I went to the App Store to get iLife '11 to update fully and it says it's Installed.
    But I checked on my MacPro and it's not installed there. Nor is it on my MBP -- how can I get it from the App Store and install it on my MacPro = it won't let me. Thank.s

    Try rename iPhoto.app in the Applications folder. Change it to something like iPhotoold or somesuch. Then try again.
    As always, before updating anything, *back up first*
    Regards
    TD

  • I want to replace the hard drive with a larger drive

    can I back up my hard drive onto Time Machine then replace with a larger drive then just use time machine to restore without reinstalling all the software??  I currently have a 5400RPM 320 GB hard drive and I want to replace with a 750 GB 7200RPM drive.

    Yes you can, but I'd advise you use cloning software and another powered external drive instead, leave the TM drive as extra backup.
    What you do is this. Get another external drive equal or larger than the 750GB drive.
    Use Disk Utility to format this drive HFS+  Journaled.
    Then download a (donations accepted, but otherwise free to use) copy of Carbon Copy Cloner, then clone your OS X boot drive to the external drive.
    Hold option and reboot the computer, you will get a choice of bootable drives, including the external drive.
    Once your booted off the clone, check it out and Repair Permissions in Disk Utility on both drives.
    Once your happy it works good. Then make the internal hard drive switch.
    When that's done, hold option and boot off the clone and simply reverse clone onto the internal drive.
    You can also hold c and boot off the installer disks and use TimeMachine to restore to the internal drive.
    However if there is a problem with your new internal drive or your disks are scratched, or your Superdrive fails, your might have nothing to boot from, with the clone you can option boot off of that and order a replacement drive or simply use it until the replacement arrives.
    (well I guess you could place the old drive back in, then switch it out again, but it's risky working inside a machine, you could lose screws or static charge something or accidentially pull a cable, so the less inside time the better, plus you'll need the larger drive anyway to TM too.)
    So you get a lot more protection that you can get online and working in a few seconds with a clone.
    TimeMachine drives are not bootable, I wish they were but they aren't.
    So it's best to have both methods at the ready in case one fails.
    (disclaimer: I haven't used TimeMachine myself my needs are more specialized, I'm quoting second hand information and may contain inaccuracies as I'm not a TM expert)
    For further information I point you to Pondini's excellent guide of the capabilities of each here.
    http://web.me.com/pondini/Time_Machine/Clones.html

  • Replace with a blank space instred of , and _

    Dear all
    I am using oracle 10g.
    I want to replace with a blank space instead of , and _.
    example
    i have a string like ABCD_EFG,HKL
    Then it should come like ABCD EFG HKL ..
    How can i do it?

    Try this:
    SELECT 'ABCD_EFG,HKL', TRANSLATE ('ABCD_EFG,HKL', '_,', '  ') FROM DUAL;

  • Trying to update to 4.0 on my Mac. When trying to drag new icon to applications folder, it says 4.o already in place (it isn't), nad do I want to relace with older version. I do this and then it says change can't be done because Firefox is in use. ??

    trying to update to 4.0 on my Mac. When trying to drag new icon to applications folder, it says 4.o already in place (it isn't), and do I want to replace with older version. I do this and then it says change can't be done because Firefox is in use. ??

    That version cannot be upgraded further if it's a 2G model. The 3G model can be upgraded to iOS 5.x.x. You can't have a 2G model because the maximum iOS version is 4.2.1.
    Upgrading iOS
       1. How to update your iPhone, iPad, or iPod Touch
       2. iPhone Support
       3. iPod Touch Support
       4. iPad Support
         a. Updating Your iOS to Version 6.0.x from iOS 5
              Tap Settings > General > Software Update
         If an update is available there will be an active Update button. If you are current,
         then you will see a gray screen with a message saying your are up to date.
         b. If you are still using iOS 4 — Updating your device to iOS 5 or later.
         c. Resolving update problems
            1. iOS - Unable to update or restore
            2. iOS- Resolving update and restore alert messages

  • Remove People from Backgrounds and Replace with Solid Grey Backgrd

    I have several photos of people with poor backgrounds that I want to replace with a solid medium grey background.
    How do I get or make the background.
    I assume I use the Quick Selection tool to select the person but I don't have an image with a solid background.

    Open you picture file
    Use one of the selection tools to select the foreground
    Go to Layer>new>layer via copy (CTRL+J)
    Place a blank layer between the background layer and the layer created in step #3
    Go to Edit>fill layer, and in the drop-down for contents select 50% gray. OK it.
    Note: In step #5 you can use any color. Set the foreground color chip to the desired color, and fill  the layer with the paintbucket tool

  • Version update and now "replace with after effects composition" is greyed out.

    Hi, I've been working on a project for a while now (using Premiere Pro cc and After Effects cc).
    Then CC 2014 came out. I installed those new Versions. To make sure that everything still works I've continued working with cc versions. Now if I want to "Replace with After Effects Composition" (in the premiere pro project opend in Version cc) it doesn't work since it's greyed out.
    Can somebody help me?

    Ok guys...I got it...
    Its not a *mov that it missplaced, its another dynamic link to AE...so dynamic link to dynamic link seems not to work? I accidently linked that clip and worked on it in AE in the old aep from yesterday..but still wondern why AE get confused loading it...the "old aep comp" is full with others comp...could that be the reason...?

  • Replacing 'word' in a string

    Hi! I want to replace Strings in a String, but if the the substring which has to be replaced is not a word, then i don't want it to be replaced. Eg.: I want to replace Words for other strings, where words are not substring of other Words :)
    Just want to ask if someone has made this before, and can help me out
    cu
    athalay

    But, my original question wasn't this. I
    want to replace words(string) for other strings in
    sentences(string). I hope it's clearer. So for example
    I have a sentence: This is an applepie. And if I want
    to replace apple for pear, then do not replace this
    sentence for pearpie, just remain it, because there's
    no "apple" word in this sentence. I hope it's clearer.
    My main problem is, that handling the First word of
    the sentence. It easy to replace " "+word+" " for what
    I want, but there are separatorchars like , . etc :)Search for the word you want to replace. Once you have found it, you will need to do a series of other checks...
    1) is it at the beginning or end of the sentence? (then you need to look at the character before or after the word depending on location in entire String to see if it is whitespace or separator character)
    2) is it surrounded by whitespace or separator characters on both sides? (get the surrounding characters and compare to a list of acceptable characters to make this a word, ie " ", ",", ";"...
    Only replace words that pass the conditions (beginning of sentence and followed by whitespace or separator, end of sentence and preceeded by whitespace or separator, or middle of sentence and surrounded by whitespace or separators).

  • 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).

  • I had two files named graphics and I replaced one graphics file with another which was the wrong one.  Can I undo my replacement?  I move the wrong one, which was on my desktop into another one and that is when it as me if I wanted to replace the file.

    I accidently replaced a file with another.  Can I undo my action? 
    I had two files named graphics.  One was on my desktop and another was within another file called solitarie.  I move the one on my desktop (wrong file) into the solitarie file and was asked if I wanted to replace the graphics file in the solitarie folder (the correct one).  I said yes accidently and then remembered that I had made a mistake.  If I use undo, it only move the wrong file back to the desktop.  Is there an undo of replace?

    Sorry, but's that's why you get the warning. "Replace" means just that - the new file over-writes the old one. There is no undo.

  • When i go to sync my apps with my computer it tells me  ''are you sure you want to sync apps ? all exsisting apps and there data on (iphone) will be replaced with the apps on this itunes library'' does this mean all my data will be lost if i continue ?

    when i go to sync my apps with my computer it tells me  ''are you sure you want to sync apps ? all exsisting apps and there data on (iphone) will be replaced with the apps on this itunes library'' does this mean all my data will be lost if i continue ?

    Regarding your broken, previously authorized computer, here's how that works:
    You would authorize your new computer -- maybe you've done that already.  Then you will have two computers authorized.  Apple allows you to have up to five computers authorized at any time.  If you get to five, you can then go to your account details in iTunes and remove all authorizations.
    Bear in mind this is not saying you can synch to more tham one library.  Razmee209 and gdgmacguy's comments above are correct.  But if Apple only allowed you to authorize one computer at a time, then having a broken computer would mean you could no longer use your Apple ID with iTunes.

  • I'm battling to change my primary iCloud account on my mac, please help? I want to replace it with my secondary account by can't find a way to do this?

    I'm battling to change my primary iCloud account on my mac, please help? I want to replace it with my secondary account by can't find a way to do this? Tony

    System Preferences/iCloud - log out and then log in with your other ID.
    https://discussions.apple.com/thread/3390335?tstart=0
    Set up iCloud
    Set up iCloud (2)

Maybe you are looking for

  • Copying a DVD on an new iMac

    First, forgive me for sounding like a complete novice. I recently purchased (Christmas 09) an iMac with the latest version of snow leopard, iLife, iWorks, etc.(was a PC user for last 15 years). My son has a DVD that was made for him by another parent

  • Sync other Outlook Calendars to iPhone

    I'm running Outlook 2003 connecting to Exchange but keeping everything in a pst. I'm currently syncing my default calendar to my - all good. I want to be able to sync a shared Calendar only and not my calendar (or even both) I can't get Itunes to see

  • Transfer Z10 contacts to Q10, link does not copy everything.

    I sued the Blackberry link to trasnfer the Z10 data to the Q10 but quite a few peoples numbers just show up with out their name.  Does anyone know what the problem is?  I have tried everything and I am tired.  I just want my Q10 to work like the Z10.

  • Music in the Cloud Won't Show in iTunes

    I was trying to fix a playlist sync problem in iTunes on my MacBook Air (the playlists I deleted would re-appear in iTunes after syncing with Match). I now seem to have a new, much more serious problem. That is, when I enable iTunes Match and verify

  • In addition to the zoom in/out issue

    I find the cursor gets stuck when I try to move it. It takes some prodding.