Hi anybody help me to find suitable validation way for Hash_Tag, My need is user should only type hash_tag like below format. a) #sports b) #sports,#news Please Help Me, Regards, Manoj. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/d1cba69e8027c2df26a0b1097152496e%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.
Manoj M. wrote in post #1113802:> Hi > anybody help me to find suitable validation way for Hash_Tag, My need is > user should only type hash_tag like below format. > a) #sports > b) #sports,#newsThere''s not enough information here to really know how to help you, but the solution will almost certainly involve regular expressions... http://www.regular-expressions.info So would the following format be invalid in your app? "Some random text #sports and some more random text #news #football." You have not specified enough detail for what you consider valid hashtags to formulate a workable regular expression. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b95f2b6c36d2c26a97e979be33bf1e73%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.
Manoj M. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi > anybody help me to find suitable validation way for Hash_Tag, My need is > user should only type hash_tag like below format. > a) #sports > b) #sports,#newsDid you really mean "Client Side Validation" as you have in your Subject: line? That means JavaScript, not ActiveRecord validations? Even if you do use Client Side validation, you really need to do Server Side as well to guard against hacks. Read about Server Side here: http://guides.rubyonrails.org/active_record_validations.html Follow Robert''s advice as well and learn some regular expression magic. You''ll need it for either side. I''m wondering altogether though, why the need to validate this? If the user is typing a stream of text, they may or may not wish to include # at some point other than as a hash tag; I think perhaps you maybe just want to extract the hash tags that match your spec, rather than declare the input invalid? I''m just speculating here, I obviously don''t know what your application is trying to do. It''s the concept of hash tags from twitter and now other services that I''m thinking of; a way to denote a specific key word to search on in a stream of text. Anyway, more code/design/info is needed to help more, I think. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/51ce5074.2576320a.0e85.52cc%40mx.google.com. For more options, visit https://groups.google.com/groups/opt_out.