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

**URL:** <https://www.ruby-forum.com/t/text-field-with-auto-complete-with-regular-expression/171911>\
**Category:** Rails\
**Created:** [July 11, 2009, 12:13pm UTC](https://www.ruby-forum.com/t/text-field-with-auto-complete-with-regular-expression/171911 "2009-07-11T12:13:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SSSSSSSSSS\_SSSSSSSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@SSSSSSSSSS\_SSSSSSSS](https://www.ruby-forum.com/u/SSSSSSSSSS_SSSSSSSS)\
**Post date:** [July 11, 2009, 12:13pm UTC](https://www.ruby-forum.com/t/text-field-with-auto-complete-with-regular-expression/171911/1 "2009-07-11T12:13:19Z")

</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”.

How can I do this?I need a help,please…
