Replace the scheme of the input {@link Path} if it matches the string to replace.
184248
public static Path replaceScheme(Path path, String replace, String replacement) {
    return new Path(replaceScheme(path.toUri(), replace, replacement));
  }
630905
function (path, replace, replacement) {
    var _path = path.replace(replace, replacement).replace(new RegExp('/{2,}', 'giu'), '/');
    return _path !== '' ? _path : '/'
  }
1005096
public static Path sanitizePath(Path path, String substitute) {
    return new Path(sanitizePath(path.toString(), substitute));
  }
302957
public boolean accept(String path) {
        if (allow.isEmpty() && deny.isEmpty()) {
            return true;
        }
        // Check if the path is denied
        for (Pattern p : deny) {
            if (p.matcher(path).matches()) {
                return false;
            }
        }

        // Check if the path is accepted
        for (Pattern p : allow) {
            if (p.matcher(path).matches()) {
                return true;
            }
        }

        // Denied by default.
        return !deny.isEmpty();
    }
324849
private boolean replaceFilePathsWithBytes(ModelNode request) throws CommandFormatException, IOException {
        boolean didReplacement = false;
        ModelNode opDesc = new ModelNode();
        opDesc.get("address").set(request.get("address"));
        opDesc.get("operation").set("read-operation-description");
        final String opName = request.get("operation").asString();
        opDesc.get("name").set(opName);
        ModelNode response = execute(opDesc, false).getResponseNode();
        if (response.hasDefined("result", "request-properties")) {
            final ModelNode requestProps = response.get("result", "request-properties");
            for (Property prop : requestProps.asPropertyList()) {
                ModelNode typeDesc = prop.getValue().get("type");
                if (typeDesc.getType() == ModelType.TYPE && typeDesc.asType() == ModelType.BYTES
                        && request.hasDefined(prop.getName())) {
                    String filePath = request.get(prop.getName()).asString();
                    File localFile = new File(filePath);
                    if (!localFile.exists())
                        continue;
                    try {
                        request.get(prop.getName()).set(Util.readBytes(localFile));
                        didReplacement = true;
                    } catch (OperationFormatException e) {
                        throw new CommandFormatException(e);
                    }
                }
            }
        }
        return didReplacement;
    }
972357
function replacePath (path, keys) {
  var index = 0;

  function replace (_, escaped, prefix, key, capture, group, suffix, escape) {
    if (escaped) {
      return escaped;
    }

    if (escape) {
      return '\\' + escape;
    }

    var repeat   = suffix === '+' || suffix === '*';
    var optional = suffix === '?' || suffix === '*';

    keys.push({
      name:      key || index++,
      delimiter: prefix || '/',
      optional:  optional,
      repeat:    repeat
    });

    prefix = prefix ? ('\\' + prefix) : '';
    capture = escapeGroup(capture || group || '[^' + (prefix || '\\/') + ']+?');

    if (repeat) {
      capture = capture + '(?:' + prefix + capture + ')*';
    }

    if (optional) {
      return '(?:' + prefix + '(' + capture + '))?';
    }

    // Basic parameter support.
    return prefix + '(' + capture + ')';
  }

  return path.replace(PATH_REGEXP, replace);
}
1368373
private String normalizePath(String path) {
		// remove double slashes & backslashes
		path = path.replace("//", "/");
		path = path.replace("\\", "/");

		return path;
	}
756142
def fix_path(path):
    
    if '\\' in path:
        path = path.replace('\\', '/')

    path = os.path.normpath(path)

    return path
1063232
private String getSlashyPath(final String path) {
        String changedPath = path;
        if (File.separatorChar != '/')
            changedPath = changedPath.replace(File.separatorChar, '/');

        return changedPath;
    }
517614
public PactDslRequestWithPath matchPath(String pathRegex, String path) {
        requestMatchers.addCategory("path").addRule(new RegexMatcher(pathRegex));
        this.path = path;
        return this;
    }
1229455
def fixPath(path):
  
  path = os.path.abspath(os.path.expanduser(path))
  if path.startswith("\\"):
    return "C:" + path

  return path
498823
public CmsSiteMatcher forDifferentScheme(String scheme) {

        try {
            URI uri = new URI(getUrl());
            URI changedUri = new URI(scheme, uri.getAuthority(), uri.getPath(), uri.getQuery(), uri.getFragment());
            CmsSiteMatcher res = new CmsSiteMatcher(changedUri.toString(), m_timeOffset);
            res.setRedirect(m_redirect);
            return res;
        } catch (Exception e) {
            LOG.error(e.getLocalizedMessage(), e);
            return null;
        }
    }
1118047
def _replace_path(self, path):
        
        if path in self._field_to_key:
            return self._field_to_key[path]
        next_key = "#f%d" % self._next_field
        self._next_field += 1
        self._field_to_key[path] = next_key
        self._fields[next_key] = path
        return next_key
1332556
function convertPath(path) {
    function indexOf(ch, startPosition) {
      var pos = path.indexOf(ch, startPosition);
      if (pos === -1)
        return pos;

      var slashNumber = 0;
      while (path.charAt(pos - 1 - slashNumber) === '\\')
        ++slashNumber;

      if (slashNumber % 2 === 0)
        return pos;

      //Skip escaped symbols
      return indexOf(ch, pos + 1);
    }

    var match;

    //RegEx should be inside loop to reset iteration
    while (match = /{([^}:]+):/g.exec(path)) {
      var deleteBegin = match.index + match[0].length - 1;
      var deleteEnd = deleteBegin;

      var unmatched = 1;
      while (unmatched !== 0) {

        var open = indexOf('{', deleteEnd + 1);
        var close = indexOf('}', deleteEnd + 1);

        if (close === -1)
          throw Error('Unmatched curly brackets in path: ' + path);

        if (open !==  -1 && open < close) {
          ++unmatched;
          deleteEnd = open;
        }
        else {
          --unmatched;
          deleteEnd = close;
        }
      }

      //For future use: regex itself is
      //path.substring(deleteBegin + 1, deleteEnd)

      path = path.slice(0, deleteBegin) + path.slice(deleteEnd);
    }

    return path;
  }
914552
def pathencode (path):
    """"""
    if isinstance(path, unicode) and not os.path.supports_unicode_filenames:
        path = path.encode(FSCODING, "replace")
    return path
177776
def _maybe_replace_path(self, match):
        
        path = match.group(0)
        if self._should_replace(path):
            return self._replace_path(path)
        else:
            return path
729669
public void replace(StringBuilder sb, CharSequence text)
    {
        if (!isCompiled())
        {
            compile();
        }
        DFAState<Replacer> st = root;
        Replacer replacer = null;
        int start = -1;
        int end = -1;
        int len = text.length();
        for (int ii=0;ii<len;ii++)
        {
            char cc = text.charAt(ii);
            st = st.transit(cc);
            if (st != null)
            {
                if (start == -1)
                {
                    start = ii; // start of match
                }
                if (st.isAccepting())
                {
                    end = ii;   // last accpting point
                    replacer = st.getToken();
                }
            }
            else
            {
                // error
                if (start != -1)
                {
                    // we have some matching
                    if (end != -1)
                    {
                        // accepted string
                        replacer.replace(sb, text, start, end+1);
                        ii = end;   // reparse after last match
                        end = -1;
                    }
                    else
                    {
                        // not accepted partial match
                        sb.append(text, start, ii+1);
                    }
                    start = -1;
                }
                else
                {
                    sb.append(cc);
                }
                st = root;
            }
        }
        if (start != -1)
        {
            // matching at end
            if (end != -1)
            {
                replacer.replace(sb, text, start, end+1);
            }
            else
            {
                sb.append(text, start, len);
            }
        }
    }