mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 15:18:01 +00:00
Update splitting-on-whitespace.md
This commit is contained in:
@@ -20,7 +20,7 @@ what you want:
|
|||||||
A quick fix might look like this:
|
A quick fix might look like this:
|
||||||
|
|
||||||
```clojure
|
```clojure
|
||||||
(clojure.string/split "double spacing wtf?" #"[ ]+")
|
(clojure.string/split "double spacing wtf?" #" +")
|
||||||
; ["double" "spacing" "wtf?"]
|
; ["double" "spacing" "wtf?"]
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -29,6 +29,6 @@ tabs and new lines. Assuming we want to split on all whitespace, we should
|
|||||||
tell our regular expression to do just that:
|
tell our regular expression to do just that:
|
||||||
|
|
||||||
```clojure
|
```clojure
|
||||||
(clojure.string/split "we\thave new\nlines and tabs\n" #"[\s]+")
|
(clojure.string/split "we\thave new\nlines and tabs\n" #"\s+")
|
||||||
; ["we" "have" "new" "lines" "and" "tabs"]
|
; ["we" "have" "new" "lines" "and" "tabs"]
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user