get_suffix.go
· 128 B · Go
Surowy
func getSuffix(fileName string) string {
regex := `\.[^\.]*$`
re, _ := regexp.Compile(regex)
return re.FindString(fileName)
}
| 1 | func getSuffix(fileName string) string { |
| 2 | regex := `\.[^\.]*$` |
| 3 | re, _ := regexp.Compile(regex) |
| 4 | return re.FindString(fileName) |
| 5 | } |
get_suffix.py
· 181 B · Python
Surowy
def get_suffix(name):
m = re.search(r"\.[^\.]*$", name)
if m.group(0) and len(m.group(0)) <= 5:
return m.group(0)
else:
return ""
| 1 | def get_suffix(name): |
| 2 | m = re.search(r"\.[^\.]*$", name) |
| 3 | if m.group(0) and len(m.group(0)) <= 5: |
| 4 | return m.group(0) |
| 5 | else: |
| 6 | return "" |