How to add quotes to either end of a string? [closed] - javascript

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I have a string that looks like this:
2014-02-23
and I want to add quotes to either end.
"2014-02-23"
What is the best way to do this?

The simplest :
'"'+s+'"'
The jsonest (only if your string doesn't contain quotes) :
JSON.stringify(s)
The regexest :
s.replace(/^|$/g,'"')
The best ? Choose your own.

Related

Javascript getElementsByTagName() and insertAdjacentHTML() [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 10 months ago.
Improve this question
I wonder where I did wrong because it needs to show like this.
But somehow it shows like this
enter image description here2
Here is my code
enter image description here3
I think function will terminate after
return imageText;

Why does it say it is assigned a value but never used? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 11 months ago.
Improve this question
I tried changing the string, and tried repeating everything over and over. Nothing seems to work.
Edit: Thanks for the replies, it is working now.
It says that you create a new variable let temperature but you are not using it anywhere in your code
If you want to use it in the alert you should use backticks `` for s tring interpolation instead of single quotes ''

How to draw double headed arrow in HTML? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
I want to create a double headed arrow/html element in my web page with some text in it. Basically an arrow like in shapes in MS Word.
Also, I want it to be clickable so that I can trigger any event on the click.
How can I accomplish this?
Some double-headed arrow characters exist in UTF-8 if you don't want to draw it yourself in CSS :
U+2194 ↔
U+2195 ↕
U+21D4 ⇔
U+21D5 ⇕
This page has a lot of them if you need more.

What is the jquery regex to match "-123x123" in this string "http://path/to/file/file-name-123x123.jpg" [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
where file name could contain any digits before the "-123x123", numbers in the "-123x123" could be any numeric values.
The answer is:
-\d+x\d+(?=\.jpg)
\d means "digit"
(?=....) means "followed by"
A link: http://regular-expressions.info

Javascript Regex replace string between 2 strings [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm trying to figure out the best way to replace a string between 2 other strings. I believe regex is necessary for this.
Input string:
"http://domainabc.com/dir1/dir2"
Output string:
"http://domainxyz.com/dir1/dir2"
Only the domain will change - not the subdirectories.
Probably you're looking to change current domain name without bothering what the domain is. Try this code:
var s = "http://domainabc.com/dir1/dir2";
repl = s.replace(/\b(https?:\/\/)[^/]+(.+)$/, "$1domainxyz.com$2");
//=> http://domainxyz.com/dir1/dir2

Categories