Leading slash but no trailing.
422637
private String cleanRoute(String route) {
        if (!route.startsWith("/")) {
            route = "/" + route;
        }

        if (route.endsWith("/")) {
            route = route.substring(0, route.length() - 1);
        }

        return route;
    }
877419
private String getPathSegment(String pattern) {
		int slash = pattern.indexOf('/', 1);
		int dot = pattern.indexOf('.', 1);
		String path;

		if (slash > 0) {
			path = pattern.substring(0, slash);
		} else if (dot > 0) {
			path = pattern.substring(0, dot);
		} else {
			path = pattern;
		}

		return path;
	}
932586
function advanceSlash() {
        var regex, previous, check;

        function testKeyword(value) {
            return value && (value.length > 1) && (value[0] >= 'a') && (value[0] <= 'z');
        }

        previous = extra.tokenValues[extra.tokens.length - 1];
        regex = (previous !== null);

        switch (previous) {
        case 'this':
        case ']':
            regex = false;
            break;

        case ')':
            check = extra.tokenValues[extra.openParenToken - 1];
            regex = (check === 'if' || check === 'while' || check === 'for' || check === 'with');
            break;

        case '}':
            // Dividing a function by anything makes little sense,
            // but we have to check for that.
            regex = false;
            if (testKeyword(extra.tokenValues[extra.openCurlyToken - 3])) {
                // Anonymous function, e.g. function(){} /42
                check = extra.tokenValues[extra.openCurlyToken - 4];
                regex = check ? (FnExprTokens.indexOf(check) < 0) : false;
            } else if (testKeyword(extra.tokenValues[extra.openCurlyToken - 4])) {
                // Named function, e.g. function f(){} /42/
                check = extra.tokenValues[extra.openCurlyToken - 5];
                regex = check ? (FnExprTokens.indexOf(check) < 0) : true;
            }
        }

        return regex ? collectRegex() : scanPunctuator();
    }
1352027
def do_slash(self,args):
        
        parser = CommandArgumentParser("slash")
        args = vars(parser.parse_args(args))
        if None == self.parent:
            print "You're at the root. Try 'quit' to quit"
        else:
            raise SlashException()
973344
def drop_trailing_zeros(num):
    
    txt = '%f' %(num)
    txt = txt.rstrip('0')
    if txt.endswith('.'):
        txt = txt[:-1]
    return txt
691281
private String maybeAddTrailingSlash(String key) {
    if (!key.isEmpty() && !key.endsWith("/")) {
      return key + '/';
    } else {
      return key;
    }
  }
358683
function leadingZeros(number, minLength = 0, padWith = '0') {
  const stringNumber = number.toString()
  const paddingLength = minLength - stringNumber.length
  return paddingLength > 0 ? `${padWith.repeat(paddingLength)}${stringNumber}` : stringNumber
}
311256
function normalize$1(path) {
              var isPathAbsolute = isAbsolute(path),
                  trailingSlash = substr(path, -1) === '/';

              // Normalize the path
              path = normalizeArray(filter(path.split('/'), function(p) {
                return !!p;
              }), !isPathAbsolute).join('/');

              if (!path && !isPathAbsolute) {
                path = '.';
              }
              if (path && trailingSlash) {
                path += '/';
              }

              return (isPathAbsolute ? '/' : '') + path;
            }
610830
static String stripLeadingSlash(String path) {
        if (path.endsWith("/")) {
            return path.substring(0, path.length() - 1);
        } else {
            return path;
        }
    }
138392
function strip(path) {
    var cur;
    var next;
    var str = '';

    for (var i = 0; i < path.length; i++) {
        cur = path.charAt(i);

        if (i !== path.length - 1) {
            next = path.charAt(i + 1);
        }

        if (cur === '/' && (next === '/' || (next === '?' && i > 0))) {
            continue;
        }

        str += cur;
    }

    return (str);
}
1090293
function (path) {
        if (!path) {
            return;
        }
        // TODO Name have slash ?
        var pathArr = path.split('/');
        var current = this;
        for (var i = 0; i < pathArr.length; i++) {
            var name = pathArr[i];
            // Skip empty
            if (!name) {
                continue;
            }
            var found = false;
            var children = current._children;
            for (var j = 0; j < children.length; j++) {
                var child = children[j];
                if (child.name === name) {
                    current = child;
                    found = true;
                    break;
                }
            }
            // Early return if not found
            if (!found) {
                return;
            }
        }

        return current;
    }
12295
function (path) {
            var result = path.match(splitPathRe) || [],
                root = result[1] || '',
                dir = result[2] || '';

            if (!root && !dir) {
                // No dirname
                return '.';
            }

            if (dir) {
                // It has a dirname, strip trailing slash
                dir = dir.substring(0, dir.length - 1);
            }

            return root + dir;
        }
417726
public static function slashless(string $s): string
	{
		$s = trim($s);
		$s = self::replace($s, '#\/{2,}#', '/');

		return $s;
	}
602234
private static String stripStartingSlash(String s) {
        if (s != null && s.startsWith("/")) {
            s = s.substring(1, s.length());
        }
        return s;
    }
689372
def leading_whitespace(self, line):  # type: (str) -> str
        
        string = ""
        for char in line:
            if char in " \t":
                string += char
                continue
            else:
                return string
        return string
921629
public static function removeTrailingSlash( $path, $slash = DIRECTORY_SEPARATOR ) {
		$path = static::normalizePath( $path, $slash );
		$path = preg_replace( '~' . preg_quote( $slash, '~' ) . '+$~', '', $path );
		return $path;
	}
1215390
public static String normalizeSlashes(final String path) {
        // prepare
        final StringBuilder builder = new StringBuilder(path);
        boolean modified = false;

        // remove all trailing '/'s except the first one
        while (builder.length() > 0 && builder.length() != 1 && PATH_SEPARATOR == builder.charAt(builder.length() - 1)) {
            builder.deleteCharAt(builder.length() - 1);
            modified = true;
        }

        // add a slash at the beginning if one isn't present
        if (builder.length() == 0 || PATH_SEPARATOR != builder.charAt(0)) {
            builder.insert(0, PATH_SEPARATOR);
            modified = true;
        }

        // only create string when it was modified
        if (modified) {
            return builder.toString();
        }

        return path;
    }