Learn R Programming

urlexplorer (version 0.1.0)

extract_file_extension: 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)

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.

Arguments

url

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

Examples

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

Run the code above in your browser using DataLab