AimerNeige revised this gist . Go to revision
1 file changed, 6 insertions, 2 deletions
get_suffix.go
@@ -1,5 +1,9 @@ | |||
1 | 1 | func getSuffix(fileName string) string { | |
2 | 2 | regex := `\.[^\.]*$` | |
3 | 3 | re, _ := regexp.Compile(regex) | |
4 | - | return re.FindString(fileName) | |
5 | - | } | |
4 | + | foundSuffix := re.FindString(fileName) | |
5 | + | if len(foundSuffix) <= 5 { | |
6 | + | return foundSuffix | |
7 | + | } | |
8 | + | return "" | |
9 | + | } |
AimerNeige revised this gist . Go to revision
1 file changed, 6 insertions, 6 deletions
get_suffix.py
@@ -1,6 +1,6 @@ | |||
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 "" | |
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 "" |
AimerNeige revised this gist . Go to revision
2 files changed, 11 insertions
get_suffix.go(file created)
@@ -0,0 +1,5 @@ | |||
1 | + | func getSuffix(fileName string) string { | |
2 | + | regex := `\.[^\.]*$` | |
3 | + | re, _ := regexp.Compile(regex) | |
4 | + | return re.FindString(fileName) | |
5 | + | } |
get_suffix.py(file created)
@@ -0,0 +1,6 @@ | |||
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 "" |