ruby - Filter through text and return the strings that start with #? -
I currently have a text form (similar to Twitter) for users to post updates, How to filter by and return full strings that start at # (For example, if a user posts "Hello World! # Nob # RUB", I will get #Nob and #RBI back) I can save in DB column. Thank you very much for your help!
You can exclude pattern-matching substrings from a large string, for example, # of Next WhiteSpace "Hello World! #Nob # RUB" .scan (/ \ # string # scan
\ S + /) # to capture all subsequent characters. = & Gt; ["#noob", "#ruby"]
Comments
Post a Comment