I want to give users a text area where they can enter text. Later I will match that input against a different input and extract it if matched.
Flow:
Then I use the following to extract:
text_reply = text_reply.sub(/#{user.text_to_extract}/m, '').strip
Problem is that it appears that characters like new lines or pipes | are breaking it. As input that we want to match against can look like this:
XXXXXX
XXXXXX
XXXX & XXXXX
asdasd: 123312321 | dasasddsadasads
http://yahoo.com
Suggestions? Thansk
In Ruby, user input is made possible by the #gets method. During the executing of a Ruby program, when a line with the #gets method is read, the terminal is primed for input from the user. The input is returned as a string type after the #gets method is finished. puts "My name is #{name}!"
E.g. (? i-sm) turns on case insensitivity, and turns off both single-line mode and multi-line mode.
Rubular is a Ruby-based regular expression editor. It's a handy way to test regular expressions as you write them. To start, enter a regular expression and a test string.
You need to escape the input: http://www.ruby-doc.org/core/classes/Regexp.html
See the method escape
.
Regexp.escape(your_input)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With