Get the last bit of the path

input: /py4e/lessons/intro?x=2
output: intro
341986
public static function get_request_document() {
        $uri = $_SERVER['REQUEST_URI'];     // /tsugi/lti/some/cool/stuff
        $pieces = explode('/',$uri);
        if ( count($pieces) > 1 ) {
            $local_path = $pieces[count($pieces)-1];
            $pos = strpos($local_path,'?');
            if ( $pos > 0 ) $local_path = substr($local_path,0,$pos);
            return $local_path;
        }
        return false;
    }
867963
def end_abs(self):
        
        if self.end == float('inf'):
            return self.track.duration
        else:
            return self.end
1346551
def fullpath(self):
        
        return str(os.path.join(self.path, self.directory))
337266
def _slice(self, start, end):
        """"""
        if end == start:
            return self.__class__()
        offset = self._offset
        startbyte, newoffset = divmod(start + offset, 8)
        endbyte = (end + offset - 1) // 8
        bs = self.__class__()
        bs._setbytes_unsafe(self._datastore.getbyteslice(startbyte, endbyte + 1), end - start, newoffset)
        return bs
1032759
protected String getLastPathLevel(String path) {

        path = path.trim();
        if (path.endsWith("/")) {
            path = path.substring(0, path.length() - 1);
        }
        if (path.contains("/")) {
            path = path.substring(path.lastIndexOf("/"));
        }
        return path;
    }
1280587
def last(pipe, items=1):
    '''  '''
    if items == 1:
        tmp=None
        for i in pipe:
            tmp=i
        return tmp
    else:
        return tuple(deque(pipe, maxlen=items))
1033296
private static String getFallbackString(String fallback) {
        int extStart = fallback.indexOf('@');
        if (extStart == -1) {
            extStart = fallback.length();
        }
        int last = fallback.lastIndexOf('_', extStart);
        if (last == -1) {
            last = 0;
        } else {
            // truncate empty segment
            while (last > 0) {
                if (fallback.charAt(last - 1) != '_') {
                    break;
                }
                last--;
            }
        }
        return fallback.substring(0, last) + fallback.substring(extStart);
    }
605793
function getPathParts(path) {
  // split the path specified into an array on `.`
  const pathParts = String(path).split('.');

  // create an empty array which will be the result
  const parts = [];

  // create an index variable so we can skip indexes if
  // need be when parsing the paths
  let index = 0;

  // while the index is smaller then the parts array length
  while (index < pathParts.length) {
    // get the part from the parts array
    let parsedPart = pathParts[index];

    // while (if) the part starts with `\` remove it and
    // append `.` and then next part from the array to it
    // this should result in `test\\.test` being parsed
    // into `test.test`. This is done so users can escape
    // dots from the dot notation
    while (parsedPart[parsedPart.length - 1] === '\\'
          && pathParts[index + 1] !== undefined
          && pathParts[index + 1] !== null) {
      // remove `\` and append the `.`
      parsedPart = `${parsedPart.slice(0, -1)}.`;
      // increase the index so next iteration it will skip
      // the next path which is about to be added to this path
      index += 1;
      // add the next path to the current one because they are
      // apart of the same object key
      parsedPart += pathParts[index];
    }

    // increase the index so we can continue to the next path
    // in the array
    index += 1;

    // append the parsed path to the results array
    parts.push(parsedPart);
  }

  // return all the parsed paths
  return parts;
}
237755
def in_single_path_and_inner(self):
        
        return len(self.successor) == 1 and self.successor[0] is not None and not self.successor[0].in_or_out and \
               len(self.precedence) == 1 and self.precedence[0] is not None and not self.successor[0].in_or_out
1037943
def __get_segmentation_path(self, path):
        
        startpath, ext = os.path.splitext(path)
        segmentation_path = startpath + "_segmentation" + ext
        return segmentation_path
749471
def last_string(self):
        """"""
        cb = self.code_builder
        len_cb = len(cb)
        if len_cb > 0:
            return cb[len_cb - 1]
        else:
            return None
1299869
function getFromOld(old, pieces) {

	var length = pieces.length,
	    result,
	    path,
	    rest,
	    i;

	for (i = 0; i < length; i++) {
		path = pieces.slice(0, length - i).join('.');

		result = old[path];

		if (typeof result != 'undefined') {

			if (i == 0) {
				return result;
			}

			rest = pieces.slice(pieces.length - i);

			result = retrieveFromPath(result, rest);

			if (typeof result != 'undefined') {
				return result;
			}
		}
	}
}
1022910
public String getLastPathSegment() {
        if (StringUtils.isBlank(path)) {
            return StringUtils.EMPTY;
        }
        String segment = path;
        segment = StringUtils.substringAfterLast(segment, "/");
        return segment;
    }
952889
def get_path_name(self):
        
        complete_path = os.path.dirname(os.path.abspath(self.path))
        name = self.path.replace(complete_path + PATH_SEPARATOR, "")
        if name.endswith("/"):
            name = name[: -1]

        return complete_path, name
858290
def full_path
      p = self
      until p.prior.nil? || p.prior.library
        p = p.prior
      end
      p.prior.nil? ? p.path : [p.prior] + p.path
    end
1089711
def prev(self):
        """"""
        seg = Segment(segment_t=idaapi.get_prev_seg(self.ea))

        if seg.ea >= self.ea:
            raise exceptions.NoMoreSegments("This is the first segment. no segments exist before it.")

        return seg
737069
def ToDebugString(self):
    """"""
    text_parts = ['Path segment index\tPath segments(s)']
    for index, path_segments in self.path_segments_per_index.items():
      text_parts.append('{0:d}\t\t\t[{1:s}]'.format(
          index, ', '.join(path_segments)))

    text_parts.append('')

    return '\n'.join(text_parts)