findlast(pattern::Regex, string::String) missing?

In Julia 1.0

julia> ?findlast

shows that the following method should exist.

findlast(pattern::Regex, string::String)

But 'methods(findlast)` shows no such method.

What needs to be corrected? The code in Base or the documentation?

The same problem exists for findprev(patter::Regex, string::String, start::Integer)

You could use findfirst(r"pattern", reverse("string")) in the mean time.

From the documentation of reverse:

Reverses a string. Technically, this function reverses the codepoints in a string
and its main utility is for reversed-order string processing, especially for
reversed regular-expression searches.

Ok, reading the news entry:
It appears that those functions should be defined, but they aren’t.

@nalimilan : Could you help us on uncovering the truth?

Provided you also reverse the pattern. I don’t know of any method that does that automatically.


AFAIK we never had a function to apply a regex backwards. Reversing strings can help achieving that, but it’s always tricky.

Finding a regex match from the end of a string is not something that most regex libraries support, as far as I’m aware. I don’t think PCRE (which we use) supports it, in particular.

1 Like

So the right move is to remove the docstring relicts?

The tricky thing is that we are able to do this for some types of needles, e.g. plain strings. For others, like regular expressions, we cannot do it. So this is unfortunately going to be a bit of a patchwork dues to implementation difficulties. But yes, that particular signature should be removed.

Seems so to me.