Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7617753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:13:37+00:00 2026-05-31T03:13:37+00:00

I have an array like this: [ee, 3/4\, 22\, 22\] and I’d like to

  • 0

I have an array like this:

["ee", "3/4\"", "22\"", "22\""]

and I’d like to either remove the commas, \" or replace that with &#34 so that the array looks like this:

["ee", "3/4", "22", "22"]

or this:

["ee", "3/4&#34", "22&#34", "22&#34"]

The reason is that I’m trying to pass that array from Ruby to JavaScript, but I keep getting an “Unterminated string constant error” and I just can’t figure out a way around it!

This is what I’m using to pass the info to JavaScript:

cut_list="from_ruby_cut(\""+c[1]+"\")"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:13:38+00:00Added an answer on May 31, 2026 at 3:13 am

    To replace each element in an array with a modified version, such as replacing the unwanted character, you can use the map! function. Inside the block, use gsub to replace the unwanted " character.

    array = ["ee", "3/4\"", "22\"", "22\""]
    
    array.map!{ |element| element.gsub(/"/, '') }
    array
    #=> ["ee", "3/4", "22", "22"]
    
    array.map!{ |element| element.gsub(/"/, '&#34') }
    array
    #=> ["ee", "3/4&#34", "22&#34", "22&#34"]
    

    However, you may also be able to solve your problem by using c[1].inspect instead of c[1] when building your JavaScript string. If you use inspect, it’ll print the string with the enclosing quotes included, and the backslash to escape the quote inside the string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array like this that defines the entry values for a ListPreference:
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>
Hello i have array like this [0] => Array ( [ExamMonth] => Array (
I have array result like this: Array ( [0] => stdClass Object ( [id_global_info]
I have an array like this: object[] args and need to insert those args
I have an array like this: $sports = array( 'Softball - Counties', 'Softball -
I have an array like this: var arr1 = [a, b, c, d]; How
I have an array like this: Array ( [23] => 540, [25] => Array
I have an array like this - (i do not know the length of
Lets say I have an array like this: string [] Filelist = ... I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.