# Strip out non-alphanumeric characters before saving to index

**URL:** <https://www.ruby-forum.com/t/strip-out-non-alphanumeric-characters-before-saving-to-index/140390>\
**Category:** Ferret\
**Created:** [June 13, 2008, 2:43pm UTC](https://www.ruby-forum.com/t/strip-out-non-alphanumeric-characters-before-saving-to-index/140390 "2008-06-13T14:43:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [June 13, 2008, 2:43pm UTC](https://www.ruby-forum.com/t/strip-out-non-alphanumeric-characters-before-saving-to-index/140390/1 "2008-06-13T14:43:47Z")

</div>

Does anyone know a simple way, with ferret or a\_a\_f, to strip out  
everything that’s not a letter, number or space before saving to the  
index? I know that i could do a custom method for every indexed field  
that regexes them out but i thought that there might be a universal  
option for it…

thanks  
max

---

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [June 16, 2008, 1:51pm UTC](https://www.ruby-forum.com/t/strip-out-non-alphanumeric-characters-before-saving-to-index/140390/2 "2008-06-16T13:51:16Z")

</div>

Hi!

That’s a typical job for an analyzer, I think Ferret’s StandardAnalyzer  
which is used by default does exactly that. If not, try RegexpAnalyzer.

Cheers,  
Jens

On Fri, Jun 13, 2008 at 02:43:47PM +0200, Max W. wrote:

> * * *
> 
> Ferret-talk mailing list  
> removed\_email\_address@domain.invalid  
> [http://rubyforge.org/mailman/listinfo/ferret-talk](http://rubyforge.org/mailman/listinfo/ferret-talk)

–  
Jens Krämer  
webit! Gesellschaft für neue Medien mbH  
Schnorrstraße 76 | 01069 Dresden  
Telefon +49 351 46766-0 | Telefax +49 351 46766-66  
removed\_email\_address@domain.invalid | [www.webit.de](http://www.webit.de)

Amtsgericht Dresden | HRB 15422  
GF Sven Haubold

---

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [June 16, 2008, 1:58pm UTC](https://www.ruby-forum.com/t/strip-out-non-alphanumeric-characters-before-saving-to-index/140390/3 "2008-06-16T13:58:24Z")

</div>

great, i’ll check those out.

thanks!  
max

2008/6/16 Jens K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
