Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make startswith, endswith work with Regex #29790

Merged
merged 17 commits into from
Feb 1, 2019
Prev Previous commit
Next Next commit
Update regex.jl
  • Loading branch information
dalum committed Nov 3, 2018
commit fc03281c8b476e4629794e9f355417ed8cc0c808
12 changes: 8 additions & 4 deletions base/regex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,10 @@ end
Return `true` if `s` starts with the regex pattern, `prefix`.

!!! note
`occursin` is recommended over the regex version of `startswith`
in performance critical situations.
`startswith` does not compile the anchoring into the regular
expression, but instead passes the anchoring as
`match_option` to PCRE. If compile time is amortized,
`occursin(r"^...", s)` is faster than `startswith(s, r"...")`.

See also [`occursin`](@ref) and [`endswith`](@ref).

Expand Down Expand Up @@ -209,8 +211,10 @@ end
Return `true` if `s` ends with the regex pattern, `suffix`.

!!! note
`occursin` is recommended over the regex version of `endswith` in
performance critical situations.
`endswith` does not compile the anchoring into the regular
expression, but instead passes the anchoring as
`match_option` to PCRE. If compile time is amortized,
`occursin(r"...$", s)` is faster than `endswith(s, r"...")`.

See also [`occursin`](@ref) and [`startswith`](@ref).

Expand Down