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
How can I write a Reg-ex Expression to check whether a string is a binary multiple of 4? I am not good at making DFA and finding expressions.
A multiple of 4 in binary is any binary number that ends with 00, so this regexp should do it:
^(?:[10]*00|00?)$
If you mean a multiple of 4 in decimal, I wouldn't do that with a regexp, except perhaps to verify that it's a number. Then I'd parse it and check whether number % 4 is zero.
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
apologies for what is probably a really simple question but I am a complete noob when it come to using regular expressions.
I am trying to create an expression that matches some set criteria together, and although I can find the code to validate these things separately I'm struggling to understand how you put it all together.
What I am looking for is an expression that validates an entered code:
It will always a start with either OR or TR and then you will have 6 digits after that e.g. TR002563
Any help would be greatly appreciated.
Try this regex:
/^(?:O|T)R[0-9]{6}$/
You can use this regex:
/^[OT]R[0-9]{6}$/
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 am writing regex to match the pattern like this.
abc:123-12-4
abc: It should be exact match including colon
123 Number match any length
- Exact Match
12 Number Match any length
- Exact match
4 Exact match
Any ideas how it can be done in a simpler way.
You can use this regex:
^abc:[0-9]+-[0-9]+-4$
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 a regular expression to only match rising numbers.
ex: 22335566 66678
but not: 444663 33997777666664
the length of the number is not fixed nor is the starting digit.
Any help please?
The best way to implement this using regex is:
^(?=\d)1*2*3*4*5*6*7*8*9*$
The regex matches:
0 or more 1's, followed by,
0 or more 2's, followed by,
0 or more 3's... and so on.
(?=\d) ensures that there is atleast 1 digit in your string.
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 8 years ago.
Improve this question
I need a regex that makes sure a values starts with either:
60, 07, or 80
and is 9 digits long
Please can someone help with this.
Thanks
^(?:60|07|80)\d{7}$ should suit your needs.
/(07|60|80)[\d]{7}/
should do it.
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 an regular expression pattern to only accept positive whole numbers. It can also accept a single zero.
I do not want to accept decimals, negative number and numbers with leading zeros.
Any suggestions?
^(0|[1-9][0-9]*)$
"[1-9][0-9]*|0"
I'd just use "[0-9]+" to represent positive whole numbers.
This will allow decimal numbers (or whole numbers) that don't start with zero:
^(([1-9]*)|(([1-9]*)\.([0-9]*)))$
If you want to allow numbers that start with zero, you can do :
^(([0-9]*)|(([0-9]*)\.([0-9]*)))$
/([1-9][0-9]*)|0/
/^0|[1-9]\d*$/