Replace the file extension.
@param attValue value to be replaced
@param extName value used to replace with
@return replaced value
8099
public static String replaceExtension(final String attValue, final String extName) {
        String fileName;
        int fileExtIndex;
        int index;

        index = attValue.indexOf(SHARP);

        if (attValue.startsWith(SHARP)) {
            return attValue;
        } else if (index != -1) {
            fileName = attValue.substring(0, index);
            fileExtIndex = fileName.lastIndexOf(DOT);
            return (fileExtIndex != -1)
                    ? fileName.substring(0, fileExtIndex) + extName + attValue.substring(index)
                            : attValue;
        } else {
            fileExtIndex = attValue.lastIndexOf(DOT);
            return (fileExtIndex != -1)
                    ? (attValue.substring(0, fileExtIndex) + extName)
                            : attValue;
        }
    }
1077868
public static String getExtension(String filename)
   {
      int index = filename.lastIndexOf('.');

      if (index >= 0)
      {
         return filename.substring(index + 1);
      }

      return "";
   }
968888
protected static String oldFileNameToViewName(String fileName) throws CouchbaseLiteException {
        if (!fileName.endsWith(kViewIndexPathExtension) || fileName.startsWith("."))
            throw new CouchbaseLiteException(Status.BAD_PARAM);
        String viewName = fileName.substring(0, fileName.indexOf("."));
        return viewName.replaceAll(":", "/");
    }
722536
public String getExtension(ProvFormat format) {
        String extension = UNKNOWN;
        if (format != null) {
            extension = extensionMap.get(format);
        }
        return extension;
    }
815866
def _format_extname(self, ext):
        """"""
        if ext is None:
            outs = ext
        else:
            outs = '{0},{1}'.format(ext[0], ext[1])
        return outs
532312
def replace_ext(filename, new_ext):
    """"""
    filename_base = os.path.splitext(filename)[0]
    new_filename = '{}.{}'.format(filename_base, new_ext)
    return new_filename
1334889
def buildNewRootname(filename, extn=None, extlist=None):
    

    # Search known suffixes to replace ('_crj.fits',...)
    _extlist = copy.deepcopy(EXTLIST)
    # Also, add a default where '_dth.fits' replaces
    # whatever extension was there ('.fits','.c1h',...)
    #_extlist.append('.')
    # Also append any user-specified extensions...
    if extlist:
        _extlist += extlist

    if isinstance(filename, fits.HDUList):
        try:
            filename = filename.filename()
        except:
            raise ValueError("Can't determine the filename of an waivered HDUList object.")
    for suffix in _extlist:
        _indx = filename.find(suffix)
        if _indx > 0: break

    if _indx < 0:
         # default to entire rootname
        _indx = len(filename)

    if extn is None:
        extn = ''

    return filename[:_indx] + extn
295589
public static String extName(String fileName) {
		if (fileName == null) {
			return null;
		}
		int index = fileName.lastIndexOf(StrUtil.DOT);
		if (index == -1) {
			return StrUtil.EMPTY;
		} else {
			String ext = fileName.substring(index + 1);
			// 扩展名中不能包含路径相关的符号
			return StrUtil.containsAny(ext, UNIX_SEPARATOR, WINDOWS_SEPARATOR) ? StrUtil.EMPTY : ext;
		}
	}
1154212
private URI replaceHREF(final QName attName, final Attributes atts) {
        URI attValue = toURI(atts.getValue(attName.getNamespaceURI(), attName.getLocalPart()));
        if (attValue != null) {
            final String fragment = attValue.getFragment();
            if (fragment != null) {
                attValue = stripFragment(attValue);
            }
            if (attValue.toString().length() != 0) {
                final URI current = currentFile.resolve(attValue);
                final FileInfo f = job.getFileInfo(current);
                if (f != null) {
                    final FileInfo cfi = job.getFileInfo(currentFile);
                    final URI currrentFileTemp = job.tempDirURI.resolve(cfi.uri);
                    final URI targetTemp = job.tempDirURI.resolve(f.uri);
                    attValue = getRelativePath(currrentFileTemp, targetTemp);
                } else if (tempFileNameScheme != null) {
                    final URI currrentFileTemp = job.tempDirURI.resolve(tempFileNameScheme.generateTempFileName(currentFile));
                    final URI targetTemp = job.tempDirURI.resolve(tempFileNameScheme.generateTempFileName(current));
                    final URI relativePath = getRelativePath(currrentFileTemp, targetTemp);
                    attValue = relativePath;
                } else {
                    attValue = getRelativePath(currentFile, current);
                }
            }
            if (fragment != null) {
                attValue = setFragment(attValue, fragment);
            }
        } else {
            return null;
        }
        return attValue;
    }
1288268
def strip_vl_extension(filename):
    """"""
    for ext in ['.vl.json', '.json']:
        if filename.endswith(ext):
            return filename[:-len(ext)]
    else:
        return filename
1320585
public static String getExtension(String fileName) {
		if (fileName==null){
			return null;
		} else {
			int number=fileName.lastIndexOf('.');
			
			if (number>=0){
				return fileName.substring(number+1, fileName.length());
			} else {
				return null;
			}
		}		
	}
1144554
public SpannableStringBuilder replace(int start, int end, CharSequence tb) {
        return replace(start, end, tb, 0, tb.length());
    }
84281
@Override
    public ExtensionDef property(String name, String value) {
        extension.getOrCreate("property@name=" + name).attribute("name", name).text(value);
        return this;
    }
357452
function rewrite_extension(source, ext) {
  var source_ext = path.extname(source);
  return (source_ext === ext) ? source : (source + ext);
}
1060807
public ExtensionElement overrideExtension(ExtensionElement extension) {
        if (extension == null) return null;
        synchronized (packetExtensions) {
            // Note that we need to use removeExtension(String, String) here. If would use
            // removeExtension(ExtensionElement) then we would remove based on the equality of ExtensionElement, which
            // is not what we want in this case.
            ExtensionElement removedExtension = removeExtension(extension.getElementName(), extension.getNamespace());
            addExtension(extension);
            return removedExtension;
        }
    }
852839
public static String getSafeExtension(final String filename) {
        // extension does not include period (.)
        final String extension = FilenameUtils.getExtension(filename);
        return isSafeExtension(extension) ? "." + extension : StringUtils.EMPTY;
    }
576472
def replace_ext(filename, ext):
    
    if ext.startswith('.'):
        ext = ext[1:]
    stem, _ = os.path.splitext(filename)
    return (stem + '.' + ext)