# Text\_field\_with\_auto\_complete with regular expression

**URL:** <https://www.ruby-forum.com/t/text-field-with-auto-complete-with-regular-expression/171955>\
**Category:** Rails\
**Created:** [July 12, 2009, 9:59am UTC](https://www.ruby-forum.com/t/text-field-with-auto-complete-with-regular-expression/171955 "2009-07-12T09:59:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4bbf92/32.png) [@michael](https://www.ruby-forum.com/u/michael)\
**Post date:** [July 12, 2009, 9:59am UTC](https://www.ruby-forum.com/t/text-field-with-auto-complete-with-regular-expression/171955/1 "2009-07-12T09:59:00Z")

</div>

I’m using text\_field\_with\_auto\_complete to index the keywords of  
something.I created a ‘resource’ model,and it has a ‘keywords’ column.  
in the resource controller:  
auto\_complete\_for :resource,:keywords  
and in the view:  
\<%= text\_field\_with\_auto\_complete :resource, :keywords, {:onfocus =\>  
“resource\_keywords\_auto\_completer.activate()”}, {:method  
=\> :get, :frequency =\> 0,:after\_update\_element =\>  
“function(element,value){” + remote\_function(:url =\>  
{:action =\> :search},:with=\>"‘keywords=’+element.value") + “}”} %\>

Let me explain it.I want to redirect to a page with parameters when  
somebody click the listed items.This is not the keystone,the keystone  
is how can I index the ‘keywords’ column with a regular expression?  
(the original regular expression doesn’t fits me).  
For example,I have a “resource” whose keywords is “Michael J.”,in  
the original condition,when I type in “ael Jac”,the “Michael J.”  
keywords can be indexed.But when type in “Jackson Michael” it can’t.I  
want the “Michael J.” to be indexed whichever I type in “jackson  
michael” or “leahciM” or “aelMich” or"sonJack". ie.separate every  
words to match the “keywords”.

I’m from China and my English maybe not good,so please understand.
