Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #49175
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Parse a sentence |
| Date | 2016-07-15 13:47 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <nmapgl$n77$1@dont-email.me> (permalink) |
Ruby:
result = " Alas poor Yorick!? I knew him well , Horatio . ".
scan(/\w+|[^\w\s]/)
===>
["Alas", "poor", "Yorick", "!", "?", "I", "knew", "him", "well",
",", "Horatio", "."]
result.join("|")
===>
"Alas|poor|Yorick|!|?|I|knew|him|well|,|Horatio|."
Ocaml:
#load "str.cma";;
let parse_sentence string =
List.fold_right
(fun el accum ->
match el with
Str.Text s -> s::accum
| Str.Delim " " -> accum
| Str.Delim s -> s::accum)
(Str.full_split (Str.regexp "[^a-zA-Z]") string)
[] ;;
let result = parse_sentence
" Alas poor Yorick!? I knew him well , Horatio . " ;;
===>
["Alas"; "poor"; "Yorick"; "!"; "?"; "I"; "knew"; "him"; "well";
","; "Horatio"; "."]
String.concat "|" result ;;
===>
"Alas|poor|Yorick|!|?|I|knew|him|well|,|Horatio|."
ANS Forth?
--
Amazon bans book. After nearly a month on the site, all traces of the book and
its 80 reviews have been removed.
http://jamesfetzer.blogspot.com/2015/11/debunking-sandy-hook-debunkers-5.html
https://www.youtube.com/watch?v=EEl_1HWFRfo
Back to comp.lang.forth | Previous | Next — Next in thread | Find similar | Unroll thread
Parse a sentence "WJ" <w_a_x_man@yahoo.com> - 2016-07-15 13:47 +0000 Re: Parse a sentence François <francois.ganza@wanadoo.fr> - 2016-07-15 07:10 -0700 Re: Parse a sentence Richard Todd <richard.wesley.todd@gmail.com> - 2016-07-15 09:35 -0700 Parse a sentence Mark Wills <markwills1970@gmail.com> - 2016-07-16 03:03 -0700 Re: Parse a sentence "WJ" <w_a_x_man@yahoo.com> - 2016-07-17 10:24 +0000 Re: Parse a sentence endlessboomcapitalism@gmail.com - 2016-07-17 21:19 -0700
csiph-web