using .gsub to double quotes and punctuation in Ruby -


i trying remove double-quoted quotations in string:

for example: "mary said "lookout"!?"

"mary said "lookout"!?" coming html form textarea tag

     <textarea id="receiver" name="receiver" class="form-control"  maxlength= "1080" type="text"></textarea> 

that put variable called words. so:

words = "mary said "lookout"!?" 

then run

words.gsub!(/[!?/a"|"/z]/, "") 

i want output read:

mary said lookout 

instead getting error,

"mary said "lookout"!?".gsub!(/[!?/a"|"/z]/, "")  syntaxerror: (irb):4: syntax error, unexpected tconstant, expecting end-of-input "mary said "lookout"!?".gsub!(/[!?/a"|"/z]/, "") 

the error getting because have not escaped speech marks. ruby doesn't understand more 2 speech marks in row unless tell they're meant there. try this:

"mary said \"lookout\"!?" 

i believe there still issue gsub well. try first , see if can further on own.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -