stripPrefix
Removes a prefix from a string if it exists.
stripPrefix
Signature
typescript
function stripPrefix(str: string, prefix: string): stringParameters
str- The string to stripprefix- The prefix to remove
Returns
String without the prefix.
Examples
typescript
import { stripPrefix } from 'strio'
stripPrefix('Hello world', 'Hello ')
// "world"
stripPrefix('test', 'foo')
// "test" (no change)Related Functions
- stripSuffix - Remove suffix
- ensureLeft - Ensure prefix