-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add parentheses to the tokenizer and IsNumber() method
- Loading branch information
Showing
5 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ | |
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
package main | ||
|
||
func main() { | ||
import "./tokenizer" | ||
|
||
func main() { | ||
example := "TÄRNÖ BEHÅLLAREThis message will be printedBEHÅLLARE" | ||
tokenizer.Tokenize(example) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package tokenizer | ||
|
||
import "regexp" | ||
|
||
// IsNumber checks if the given character is a number and returns the condition | ||
func IsNumber(character string) bool { | ||
numberRegex := regexp.MustCompile(`\d`) | ||
|
||
return numberRegex.Match([]byte(character)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package tokenizer | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestIsNumber(t *testing.T) { | ||
number := "1" | ||
|
||
if !IsNumber(number) { | ||
t.Errorf("IsNumber() failed.") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters