extract_file_extension: Extract file extension from URLs or paths

View source: R/extract.R

extract_file_extensionR Documentation

Extract file extension from URLs or paths

Description

This function parses each input URL or path and extracts the file extension, if present. It is particularly useful for identifying the type of files referenced in URLs.

Usage

extract_file_extension(url)

Arguments

url

A character vector of URLs or paths from which to extract file extensions.

Value

A character vector with the file extension for each URL or path. Extensions are returned without the dot (e.g., "jpg" instead of ".jpg"), and URLs or paths without extensions will return NA.

Examples

extract_file_extension(
  c(
    "http://example.com/image.jpg",
    "https://example.com/archive.zip",
    "http://example.com/"
  )
)

urlexplorer documentation built on Aug. 8, 2025, 7:29 p.m.