Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed " == true" from if statements. #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions 01-chapter1.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You want to know if a string matches a regular expression. The *MatchString*-fun
}

// Will print 'Match'
if r.MatchString("Hello Regular Expression.") == true {
if r.MatchString("Hello Regular Expression.") {
fmt.Printf("Match ")
} else {
fmt.Printf("No match ")
Expand Down Expand Up @@ -116,7 +116,7 @@ The dot '.' matches any character.
Finding one backslash '\': It must be escaped twice in the regex and once in the string.

r, err := regexp.Compile(`C:\\\\`)
if r.MatchString("Working on drive C:\\") == true {
if r.MatchString("Working on drive C:\\") {
fmt.Printf("Matches.") // <---
} else {
fmt.Printf("No match.")
Expand All @@ -125,7 +125,7 @@ Finding one backslash '\': It must be escaped twice in the regex and once in the
Finding a literal dot:

r, err := regexp.Compile(`\.`)
if r.MatchString("Short.") == true {
if r.MatchString("Short.") {
fmt.Printf("Has a dot.") // <---
} else {
fmt.Printf("Has no dot.")
Expand Down Expand Up @@ -303,7 +303,7 @@ talking about the 26 letters in ASCII range 65-90, not including letters with di
Example: Find a sequence of a lower case letter, a punctuation character, a space (blank) and a digit:

r, err := regexp.Compile(`[[:lower:]][[:punct:]][[:blank:]][[:digit:]]`)
if r.MatchString("Fred: 12345769") == true {
if r.MatchString("Fred: 12345769") {
----
fmt.Printf("Match ") //
} else {
Expand All @@ -326,7 +326,7 @@ We start with a simple example from the Greek code block.

r, err := regexp.Compile(`\p{Greek}`)

if r.MatchString("This is all Γςεεκ to me.") == true {
if r.MatchString("This is all Γςεεκ to me.") {
fmt.Printf("Match ") // Will print 'Match'
} else {
fmt.Printf("No match ")
Expand All @@ -337,7 +337,7 @@ doesn't qualify, because \p{Greek} covers only
http://en.wikipedia.org/wiki/Greek_and_Coptic
the range U+0370..U+03FF.

if r.MatchString("the µ is right before ¶") == true {
if r.MatchString("the µ is right before ¶") {
fmt.Printf("Match ")
} else {
fmt.Printf("No match ") // Will print 'No match'
Expand All @@ -347,7 +347,7 @@ Some extra cool letters from the Greek and Coptic
codepage that qualify as 'Greek' although they are
probably Coptic, so be careful.

if r.MatchString("ϵ϶ϓϔϕϖϗϘϙϚϛϜ") == true {
if r.MatchString("ϵ϶ϓϔϕϖϗϘϙϚϛϜ") {
fmt.Printf("Match ") // Will print 'Match'
} else {
fmt.Printf("No match ")
Expand All @@ -359,7 +359,7 @@ You have to use a font that supports [Braille](http://en.wikipedia.org/wiki/Brai
I have my doubts that this is useful unless combined with a Braille capable printer, but there you go.

r2, err := regexp.Compile(`\p{Braille}`)
if r2.MatchString("This is all ⢓⢔⢕⢖⢗⢘⢙⢚⢛ to me.") == true {
if r2.MatchString("This is all ⢓⢔⢕⢖⢗⢘⢙⢚⢛ to me.") {
fmt.Printf("Match ") // Will print 'Match'
} else {
fmt.Printf("No match ")
Expand All @@ -371,7 +371,7 @@ You have to use a font that supports Cherokee (e.g. Code2000).
The story of the Cherokee script is definitely worth [reading about](http://en.wikipedia.org/wiki/Cherokee#Language_and_writing_system "Cherokee").

r3, err := regexp.Compile(`\p{Cherokee}`)
if r3.MatchString("This is all ᏯᏰᏱᏲᏳᏴ to me.") == true {
if r3.MatchString("This is all ᏯᏰᏱᏲᏳᏴ to me.") {
fmt.Printf("Match ") // Will print 'Match'
} else {
fmt.Printf("No match ")
Expand Down