Does it matter which ' and " marks are used? [duplicate] - javascript

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
When to Use Double or Single Quotes in JavaScript
Are single quotes valid in HTML/XHTML?
In the world of XHTML, HTML, Javascript etc. does it matter if you use ' or " when writing code as long as you stick to one or the other? And is it better to use one over the other and why?

being XML, XHTML will only take the double quote. HTML being SGML can take either. JavaScript, though, doesn't care as long as you are consistent withing a single string (that is opening and closing with the same character).

Related

How to translate ruby regex to javascript regex? [duplicate]

This question already has answers here:
Regex match entire words only
(7 answers)
Closed 3 years ago.
Im using validates_format_of method to check a input text
Javascript cant read this regex. How or where I can change this regex to be as original:
(?<=^|,|\b)[1-7](?=$|,|\b)
Thanks
UPDATE:
the input text must be one o more digits separated by comma, ex: 1|1,2|1,2,3
As #wiktor said you should use
\b[1-7]\b
As \b only asserts positions, you don't need to worry about matching more than [1-7].
#Code Maniac correctly stated that look behind is not supported in Mozilla and many others, so about it. see

How can create a regular expression for this URL? [duplicate]

This question already has an answer here:
Learning Regular Expressions [closed]
(1 answer)
Closed 4 years ago.
I'm not good with RegEx and I would like have a RegEx for next URL scheme.
Can you help me to create a regular expression for that URL?
https://fonts/mapbox/{fontstack}/{range}.pbf
And if possible, show me one page to learn and understand it.
The best page I use to explain RegEx is https://regex101.com/.
In case your characters are all word characters, you can just use:
https://fonts/mapbox/(\w+)/(\w+).pbf
In the first group you will have "fontstack" and in the second you will have "range".
If you want to include a bit more of possible characters, maybe:
https://fonts/mapbox/([^\s\/])/([^\s\/]).pbf
You can see extensive explanations to both introducing them on the page I provided at the start.

Are there differences between ' and " [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
When to Use Double or Single Quotes in JavaScript
Difference between single quotes and double quotes in Javascript
I searched this website and google (in that exact order...) looking for:
Are there any differences between ' and " regarding to strings in Javascript\ JQuery?
Didn't find a thing...
As long as you pair them properly there is no difference.
No, there's no difference at all. It's a matter of personal preference.
Can be used interchangeably in terms of jquery selectors. Once one is chosen for enclosing selector string, then inner quotes will use the "other one", or perhaps be escaped.

Should I use single quotation mark or double to describe jquery? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
When to Use Double or Single Quotes in JavaScript
I'm confusing what I should use in jQuery.
Some use single some use double quotation mark.
For example
$('.class1').removeClass('class1')
$(".class1").removeClass("class1")
Also, alert as well
alert("aa");
alert('aa');
which one is correct?
This is more a matter of preference than correctness. See this question for more details: When to use double or single quotes in JavaScript?

why break this up javascript fragment? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Why split the <script> tag when writing it with document.write()?
I don't really do Javascript programming and was hard to google this but have seen something like this in a couple of different places (by good developers):
document.writeln('<scr'+'ipt src="'+pcheck+'" type="text/javascript"></scr'+'ipt>');
With the split always between the r and the i. What does this achieve?
This is to prevent any script blockers from loading this script, because they cannot find the "script" word within the text.

Categories