JuliaLang/julia — pull request #3525 by nutsiepully (2013-06-24 19:28:53+00:00)
Title: match_all function to match all occurrences of a regex pattern in a string

These commits add the ability to match all occurrences of a regex pattern in a given string. (Similar to the perl ```/g``` option or the ruby ```scan```)

So, now one can search for all matches as follows.

```
julia> str = "The dark side of the moon"
"The dark side of the moon"

julia> match_all(r"(\w+)(\s*)", str)
6-element RegexMatch Array:
RegexMatch("The ", 1="The", 2=" ")
RegexMatch("dark ", 1="dark", 2=" ")
⋮
RegexMatch("the ", 1="the", 2=" ")
RegexMatch("moon", 1="moon", 2="")

```

```
#Test with Unicode

julia> s = "x \u2200 x \u2203 y"
"x ∀ x ∃ y"

julia> match_all(r".\s", s)
4-element RegexMatch Array:
RegexMatch("x ")
RegexMatch("∀ ")
RegexMatch("x ")
RegexMatch("∃ ")
```

```
#Test with empty strings matches

r = r"a?b?"
match_all(r, "asbds")

julia> match_all(r, "asbd")
5-element RegexMatch Array:
RegexMatch("a")
RegexMatch("")
RegexMatch("b")
RegexMatch("")
RegexMatch("")
```

This is an initial pull request and there are still a couple of things pending -

1. Support for CRLF
2. Test code to be put in