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
Suppose I have a number like 1234. I want to add new number 00 and , and € at the end. Now number will be like 1234,00€ I can not figure out.
That will work for you:
var value = '1234';
var formatted = value.replace(/(\d+)/, '$1,00€');
But, I strongly recommend you to read the answers in this question: How can I format numbers as money in JavaScript?
Update as #jared said, you can just concatenate the text: ,00€ to your number to just get the desired results.
Related
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 need to write a JavaScript function which accepts IP range or subnets and validate it.
Like 10.0.0.1/24 should return true
10.0.0.1-10.0.0.10 should return true.
Use:
((\b|\.)(1|2(?!5(?=6|7|8|9)|6|7|8|9))?\d{1,2}){4}(-((\b|\.)(1|2(?!5(?=6|7|8|9)|6|7|8|9))?\d{1,2}){4}|\/((1|2|3(?=1|2))\d|\d))\b
http://regex101.com/r/aJ6jK2
This one also allows leading zeros:
((\b|\.)(0|1|2(?!5(?=6|7|8|9)|6|7|8|9))?\d{1,2}){4}(-((\b|\.)(0|1|2(?!5(?=6|7|8|9)|6|7|8|9))?\d{1,2}){4}|\/((0|1|2|3(?=1|2))\d|\d))\b
http://regex101.com/r/tT8sC5
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
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
This is my radical expression:
var equation1 = "\\sqrt[4]{8}";
var equation2 = "\\sqrt[6]{x^2}";
How to get answer of this using javascript.
JavaScript's exponentiation function is Math.pow(base, exponent), so the 4th root of 8 is Math.pow(8, 1/4).
See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow?redirectlocale=en-US&redirectslug=JavaScript%2FReference%2FGlobal_Objects%2FMath%2Fpow et al.
If you're asking how to parse those strings of yours and evaluate, that's a different thing altogether.
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 have this original code. Can I know what is the meaning of this code? I confuse a bit.
if (/^\d{5}(-\d{4})?$/.test(zip.value)) {
I need to rewrite to zip code with 6 numeric digit excluding space. How should I do?
you can find your explanation here: http://rick.measham.id.au/paste/explain.pl?regex=%2F%5E%5Cd%7B5%7D%28-%5Cd%7B4%7D%29%3F%24%2F
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
DHTML page which accepts user input into the text field as integers. when the user pressed the "Display" button, your function created in javascript should able to display the sum of the entire integers in an alert message.
Example
Input :
"21547524"
Output:
"2+1+5+4+7+5+2+4 = 30"
var input="21547524";
var additions=input.split('').join('+');
alert(additions+' = '+eval(additions));