Regular expression to extract Max and Min values [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
67 to 90 or 67 - 90. I need to check for the "-" and the "to" so i can split the values into min and maximum

Showing some work is encouraged on Stack Overflow -- but this is quick and easy; I think this should do it for you:
(\d{1,3}) ?(\-|to) ?(\d{1,3})
(\d{1,3}) - an integer of 1 to 3 digits (change the second number if you want larger or smaller values.
? - an optional space (remove the ? if the space isn't optional)
(\-|to) - a hyphen or the word "to"
? - an optional space (remove the ? if the space isn't optional)
(\d{1,3}) - an integer of 1 to 3 digits (change the second number if you want larger or smaller values.
Example: https://regex101.com/r/yN4sP8/1

Related

Regular Expressions Vue [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 21 hours ago.
The community is reviewing whether to reopen this question as of 10 hours ago.
Improve this question
I'm trying to validate an input with regEx in Vue, which I don't have any idea how to make one and couldn't find online how to match what I want to do.
The thing is I'm trying to validate a price that should be a float with 2 decimal numbers, and it can be 1 number before the . or 9 digits. For example:
0.50
1.00
99999.99
999999999.00
I tried this:
v => (/\d{1,3}(?:[.,]\d{3})*(?:[.,]\d{2})/.test(v))
But doesn't work.
Sorry if my english is not very good. I appreciate the help!
To match 1-9 digits before the dot, and 2 decimal numbers:
^\d{1,9}\.\d{1,2}$
See a regex101 demo.
What do you want? Check the value for matching a number from 0 to 999999999 in the integer part and no more than 2 numbers after "."?
A template assuming that the entire string being checked from the beginning (^) to the end ($) consists of
mandatory initial part, which is either 0 or contains from 1 to 9 digits, and does not start with "0" ;
optional ending of "." and two digits:
^([1-9]\d{0,8}|0)(.\d{1,2})?$

Convert 17digit number string to a integer [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I want to convert a 17digit number string into a number
this is the number "76561197962169398".I tried using parseInt()
The result of using parseInt is :-
76561197962169390
I am loosing the last digit.I also tried BigInt() 'n' is getting appended to the number.
I m thinking of using replace() with a regex for only digits.
Is there any other way I can achieve this without loosing precision.
Please any help regarding this is really appriciated.THANK YOU
in chrome 83 devtools:
x=76561197962169398n
76561197962169398n
++x
76561197962169399n
typeof x
"bigint"
y=BigInt("76561197962169398")
76561197962169398n
++y
76561197962169399n
x+y
153122395924338798n
x + 1
VM342:1 Uncaught TypeError: Cannot mix BigInt and other types, use explicit conversions
at <anonymous>:1:2
(anonymous) # VM342:1
x + 1n
76561197962169400n
[5n, 3n, 9n, 7n].sort()
[3n, 5n, 7n, 9n]
The n suffix is for display - and in code it's needed to say a literal value needs to be treated as bigint instead of number - think of it like quotes for strings - without quotes a sequence of characters is not a string - similarly a number without n suffix is not a bigint - it's a number that has limited precision and simply cannot be used for large values

javascript - mail exchange server string validation using regex [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
how can validate a mx server (similar to a domain) in the form of mx*.m**p.com by Regex? The first star can be any number without its length pre-defined 1, 11, 111, 1111, without leading 0s. The 2nd and 3rd stars are single letters in range of 0-9 and a-Z.
Examples:
mx1.m0bp.com
mx321.maBp.com
^mx[1-9][0-9]*\.m[0-9a-zA-Z]{2}p\.com$
^ indicates the start of the string
mx are the expected characters
[1-9] The number must not have a leading zero, so it must start with 1-9
[0-9]* Followed by zero or more other digits
\. The dot must be escaped as it has a special meaning
[0-9a-zA-Z]{2} Exactly two characters with the given range
p\.com again the next expected characters with another escaped dot
$ indicates the end of the string
Including the ^ and $ means you won't get a match from foomx1.m0bp.com or mx1.m0bp.comfoo
You can use the below regex to test the domain:
mx[0-9]+\.m[0-9a-zA-Z]{2}p\.com
console.log(/mx[0-9]+\.m[0-9a-zA-Z]{2}p\.com/gi.test("mx1.m0bp.com"))
console.log(/mx[0-9]+\.m[0-9a-zA-Z]{2}p\.com/gi.test("mx321.maBp.com"))

Javascript: What is best approach to generate unique numeric string? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
What is best approach out of below options:
option 1:
var d = new Date();
uniqueString = d.getTime();
option 2:
uniqueString = Math.random();
It is possible (however unlikely) that by using dates (sequential, not random) that two different instances could coincide.
The odds of an overlap from Math.random() are much lower (again possible, however unlikely).
Out of the two I would go for the second option.
While getTime() would yield 13 digits, most of them being constant in a period of weeks, random() would randomize a number with about 16 digits.
Note that if by numeric you mean digits only, then you would have to work a little more to get rid of the 0. part of the randomized number.

how to set company name should start with character javascript validation rule? it can contain Numbers and special characters followed by character [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i want to set validation rule for company names which should start with character and it can contain numbers and special characters..
For example:
360 Angel - should not be allowed
Angel 360 - Allowed
Javascript regular expressions should help
Documentation:
http://www.javascriptkit.com/javatutors/redev3.shtml
Simple example:
var str = "360 Angel";
/^[a-zA-Z].*/.test(str); // return false

Categories