Last active
January 4, 2016 05:29
-
-
Save amencarini/8575796 to your computer and use it in GitHub Desktop.
1) Parse a list of words 2) Change words in a text if the word is contained in the list. The change should be from word to <word> 3) Print result
This file contains hidden or 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
Collaboratively administrate empowered markets via plug-and-play networks. Dynamically procrastinate B2C users after installed base benefits. Dramatically visualize customer directed convergence without revolutionary ROI. | |
Efficiently unleash cross-media information without cross-media value. Quickly maximize timely deliverables for real-time schemas. Dramatically maintain clicks-and-mortar solutions without functional solutions. | |
Completely synergize resource sucking relationships via premier niche markets. Professionally cultivate one-to-one customer service with robust ideas. Dynamically innovate resource-leveling customer service for state of the art customer service. | |
Globally incubate standards compliant channels before scalable benefits. Quickly disseminate superior deliverables whereas web-enabled applications. Quickly drive clicks-and-mortar catalysts for change before vertical architectures. | |
Credibly reintermediate backend ideas for cross-platform models. Continually reintermediate integrated processes through technically sound intellectual capital. Holistically foster superior methodologies without market-driven best practices. | |
Distinctively exploit optimal alignments for intuitive bandwidth. Quickly coordinate e-business applications through revolutionary catalysts for change. Seamlessly underwhelm optimal testing procedures whereas bricks-and-clicks processes. |
This file contains hidden or 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
package main | |
import ( | |
"os" | |
"fmt" | |
"bufio" | |
"io/ioutil" | |
"regexp" | |
) | |
var ( | |
entries []string | |
) | |
func subString(s string) string { | |
for _, entry := range entries { | |
if entry == s { | |
return fmt.Sprintf("<%s>", s) | |
} | |
} | |
return s | |
} | |
func main() { | |
wordsPath := "/usr/share/dict/words" | |
wordsFile, _ := os.Open(wordsPath) | |
scanner := bufio.NewScanner(wordsFile) | |
for scanner.Scan() { | |
entries = append(entries, scanner.Text()) | |
} | |
fileContents, _ := ioutil.ReadFile("long.txt") | |
fileString := string (fileContents) | |
reg, _ := regexp.Compile("[^ \n]+") | |
result := reg.ReplaceAllStringFunc(fileString, subString) | |
fmt.Print(result) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment