# IRB - Switching "comment mode"

**URL:** <https://www.ruby-forum.com/t/irb-switching-comment-mode/75897>\
**Category:** Ruby\
**Created:** [November 14, 2006, 3:28am UTC](https://www.ruby-forum.com/t/irb-switching-comment-mode/75897 "2006-11-14T03:28:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [November 14, 2006, 3:28am UTC](https://www.ruby-forum.com/t/irb-switching-comment-mode/75897/1 "2006-11-14T03:28:29Z")

</div>

Hi,  
I’ve been trying to solve this thing on my TODO list for some time  
(ok, it’s just on my list, and not of highest priority ;-)), and  
finally thought I’d post here.

In IRB, I would like to be able to apply a filter  
when something is input to IRB (normally, copy pasted  
in my example).  
For example, I’d like to filter all lines that start  
with a ‘#’, and gsub this with ‘’ so that  
comments are evaluated instead.  
Right now, when i copy/paste, i remove leading #'s  
manually. Right now i’d picture using a little method  
that switches between my "comment mode"s.

Now, making such a Regex is trivial. But how could I  
apply a filter on IRB? I’d not mind to hack  
up my irb but I dont even really figure out how IRB  
gets all its things done. (That way I could apply a method  
before that input, and depending on a global flag/var,  
filter, or not filter that input)
