I have a URL for a file that I need to display to users after slicing. Initially, I successfully sliced the URL using substring
, but now I face an issue with varying numbers in the string to be sliced. For example, if the URL is /media/users/3/sample.docx
, I only want to show sample.docx
. My current approach involves using substring
at a fixed position (15), but what if the number before "sample.docx" changes? How can I improve this method?
sliceString(value) {
return value.substring(15)
}
{{sliceString(data.file)}}