# Question about any possible text manipulation tools for 'fine-tuning' introspection (reflection) output

**URL:** <https://discourse.julialang.org/t/question-about-any-possible-text-manipulation-tools-for-fine-tuning-introspection-reflection-output/75175>\
**Category:** New to Julia\
**Created:** [January 25, 2022, 2:35pm UTC](https://discourse.julialang.org/t/question-about-any-possible-text-manipulation-tools-for-fine-tuning-introspection-reflection-output/75175 "2022-01-25T14:35:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxild](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxild/32/33165_2.png) [@maxild](https://discourse.julialang.org/u/maxild)\
**Post date:** [January 25, 2022, 2:35pm UTC](https://discourse.julialang.org/t/question-about-any-possible-text-manipulation-tools-for-fine-tuning-introspection-reflection-output/75175/1 "2022-01-25T14:35:11Z")

</div>

Is it possible to use some kind of ‘pattern/string match’ in the REPL when inspecting dispatch tables of functions with hundreds of methods.

Like…

```julia
methods(convert) | grep 'some pattern like <: Number or :> Number'

```

I guess text search is not ideal, but could be useful for searching on which file defined them or the type arguments.

I guess I am basically asking for a way to search for a subset of the methods (off course I can directly use the @which macro to inspect any specific dispatch).

I guess I am basically asking, if I can combine the julia REPL with the unix shell “simultaneosly” somehow, or (more realistically 😃) if Julia has some text manipulation tools built-in that can be used to “manipulate” text output (like grep) ? I all ready found pwd(), cd(“some-rel-path”) that mimick the shell filesystem tools.

---

<div class="post-metadata">

**Author:** ![Jeff\_Emanuel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff_emanuel/32/15440_2.png) [@Jeff\_Emanuel](https://discourse.julialang.org/u/Jeff_Emanuel)\
**Post date:** [January 25, 2022, 3:24pm UTC](https://discourse.julialang.org/t/question-about-any-possible-text-manipulation-tools-for-fine-tuning-introspection-reflection-output/75175/2 "2022-01-25T15:24:03Z")

</div>

```julia
for m in methods(convert)
       if occursin("Float",string(m.sig)); println(m); end
end

```

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [January 25, 2022, 3:42pm UTC](https://discourse.julialang.org/t/question-about-any-possible-text-manipulation-tools-for-fine-tuning-introspection-reflection-output/75175/3 "2022-01-25T15:42:31Z")

</div>

Here are some pipe-oriented options:

1. `methods(convert)` returns an array. You can use the full power of the language to filter the elements:

2. Convert the whole output to text and still use the language on the result:

3. Actually use the system’s `grep`:

4. Use TerminalPager.jl. That’s probably the most pragmatic for your use case! With this package you can simply do

Also note that in Julia 1.8 you will be able to TAB-complete method arguments in the help mode, for example typing `?convert(Number,` and pressing `TAB` will show all the `convert` methods that accept a `Number` as first parameter:

```julia
help?> convert(Number,
convert(::Type{T}, x::T) where T<:Number in Base at number.jl:6
convert(::Type{T}, x::Number) where T<:Number in Base at number.jl:7
convert(::Type{T}, x::Base.TwicePrecision) where T<:Number in Base at twiceprecision.jl:273
convert(::Type{T}, x::AbstractChar) where T<:Number in Base at char.jl:185
convert(::Type{T}, index::CartesianIndex{1}) where T<:Number in Base.IteratorsMD at multidimensional.jl:130
convert(::Type{T}, x::T) where T in Base at essentials.jl:215

```

Finally, if you think the pipe examples above are a bit clumsy you are not alone, hopefully [this](https://github.com/JuliaLang/julia/pull/24990) PR will be merged one day do make it nicer. With that PR the above examples would become:

```julia
methods(convert) |> filter(contains("Number")∘string, _)

methods(convert) |> string |> split(_, '\n') |> filter(contains("Number"), _)

methods(convert) |> string |> IOBuffer |> pipeline(_, `grep Number`) |> run

```

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [January 25, 2022, 3:57pm UTC](https://discourse.julialang.org/t/question-about-any-possible-text-manipulation-tools-for-fine-tuning-introspection-reflection-output/75175/4 "2022-01-25T15:57:38Z")

</div>

Might also be useful  
[https://github.com/GlenHertz/Grep.jl](https://github.com/GlenHertz/Grep.jl)

---

<div class="post-metadata">

**Author:** ![maxild](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxild/32/33165_2.png) [@maxild](https://discourse.julialang.org/u/maxild)\
**Post date:** [January 25, 2022, 5:28pm UTC](https://discourse.julialang.org/t/question-about-any-possible-text-manipulation-tools-for-fine-tuning-introspection-reflection-output/75175/5 "2022-01-25T17:28:48Z")

</div>

Dead simple. Thx

---

<div class="post-metadata">

**Author:** ![maxild](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxild/32/33165_2.png) [@maxild](https://discourse.julialang.org/u/maxild)\
**Post date:** [January 25, 2022, 5:29pm UTC](https://discourse.julialang.org/t/question-about-any-possible-text-manipulation-tools-for-fine-tuning-introspection-reflection-output/75175/6 "2022-01-25T17:29:40Z")

</div>

Elegant 👍

---

<div class="post-metadata">

**Author:** ![maxild](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxild/32/33165_2.png) [@maxild](https://discourse.julialang.org/u/maxild)\
**Post date:** [January 25, 2022, 5:38pm UTC](https://discourse.julialang.org/t/question-about-any-possible-text-manipulation-tools-for-fine-tuning-introspection-reflection-output/75175/7 "2022-01-25T17:38:27Z")

</div>

So many reasons to ‘opt my game’ in how to combine and transform text from within julia, and even subprocess to non-julia (unix) tools. Great answers. Thanks a lot. This is learning Julia by learning Julias library API’s (meta learning 😀)
