# Questions about string

**URL:** <https://discourse.julialang.org/t/questions-about-string/88604>\
**Category:** New to Julia\
**Tags:** question, strings, regex\
**Created:** [October 12, 2022, 3:51am UTC](https://discourse.julialang.org/t/questions-about-string/88604 "2022-10-12T03:51:49Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [October 12, 2022, 4:55am UTC](https://discourse.julialang.org/t/questions-about-string/88604/2 "2022-10-12T04:55:46Z")

</div>

You can use [lookaround operators](https://www.regular-expressions.info/lookaround.html)

```julia
julia> c = "9S45M11S"
"9S45M11S"

julia> eachmatch(r"\d+(?=S)", c)
Base.RegexMatchIterator(r"\d+(?=S)", "9S45M11S", false)

```

They actually match only the numbers:

```julia
julia> collect(eachmatch(r"\d+(?=S)", c))
2-element Vector{RegexMatch}:
 RegexMatch("9")
 RegexMatch("11")

```

Now, I would have expected this to work, but sadly, and confusingly, it doesn’t:

```julia
julia> parse.(Int, eachmatch(r"\d+(?=S)", c))
ERROR: MethodError: no method matching parse(::Type{Int64}, ::RegexMatch)

```

Instead, it seems I must dig around in the internals of the match object, for example like this:

```julia
julia> [parse(Int, m.match) for m in eachmatch(r"\d+(?=S)", c)]
2-element Vector{Int64}:
  9
 11

```

This should be very efficient, but it’s not nice to have to dig into the internal `match` field of the object, and it always seemed to me like an outlier in the language.

---

_[View the full topic](https://discourse.julialang.org/t/questions-about-string/88604)._
