Note that there are some explanatory texts on larger screens.

plurals
  1. PORuby on rails regular expression
    primarykey
    data
    text
    <p>In my rails application I need to implement regular expression for matching a string anywhere near the starting, ending and middle of a text. That is if the query word is "Gabbar Singh" it should match "Gabbar" or "Gabbar Singh". I implemented it using % % symbol.Its working but its not working if "Gabbar Singh" occurs in the middle of a word . for example if some text cantains "#GabbarSingh " , its not showing that particular result.</p> <p>My line of code for controller.</p> <pre><code>@tweets = Tweets.where("tweet_text LIKE?", "%#{search_term}%") </code></pre> <p>My code for the view</p> <pre><code>&lt;% @tweets.each do |tweets| %&gt; &lt;ul&gt; &lt;li&gt;&lt;%= tweets.id %&gt;&lt;/li&gt; &lt;li&gt;&lt;%= tweets.tweet_created_at %&gt;&lt;/li&gt; &lt;li&gt;&lt;%= tweets.tweet_source %&gt;&lt;/li&gt; &lt;li&gt;&lt;%= tweets.tweet_text %&gt;&lt;/li&gt; &lt;li&gt;&lt;%= tweets.user_id %&gt;&lt;/li&gt; &lt;li&gt;&lt;%= tweets.user_name %&gt;&lt;/li&gt; &lt;li&gt;&lt;%= tweets.user_sc_name %&gt;&lt;/li&gt; &lt;li&gt;&lt;%= tweets.user_loc %&gt;&lt;/li&gt; &lt;li&gt;&lt;%= tweets.user_img %&gt;&lt;/li&gt; &lt;li&gt;&lt;%= tweets.longitude %&gt;&lt;/li&gt; &lt;li&gt;&lt;%= tweets.latitude %&gt;&lt;/li&gt; &lt;li&gt;&lt;%= tweets.place %&gt;&lt;/li&gt; &lt;li&gt;&lt;%= tweets.country %&gt;&lt;/li&gt; &lt;% end %&gt; &lt;/ul&gt; </code></pre> <p>I want my results to match anything that has "Gabbar Singh" also in the middle of a string or a word. Anybody help me with this .</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload