I’m trying to highlight every digit sequence in a text using the Highlight method. I can achieve this passing an array of numbers, but that way each number is highlighted individually. I’d like to highlight the whole sequence.
Is it possible to use Highlight with Regexp? I’m receiving the following error:
highlight(text,/\d+/)
can’t convert Regexp to String
Thanks
Unfortunately not! But you can use the source of the
highlightmethod as inspiration to write your own helper that does exactly what you need.If you feel comfortable, you can propose a patch to Rails to include this feature!