Regex for these strings [closed] - regex

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
I'm having difficulty catching some strings. I want a regex to catch the strings in this list:
1
2
3
4
5
6
7
8a
8b
8c
8d
9
There will only be a letter after the number 8, and 8 will always have a following letter (a-d). The rest of the numbers will not have a letter following them.
Thanks

You can use:
[1-7]|9|8[abcd]
Depending on whether you want the whole string to match, so that nothing else follows or precedes the match, you may need to add anchors:
^([1-7]|9|8[abcd])$
Or, alternatively, if you just want to match digits that are not followed by a letter (a, b, c, d) except when it is 8 (where it is required), then:
([1-7]|9)(?![abcd])|8[abcd]

Related

Determining both kinds of situations with Regex [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 3 years ago.
Improve this question
The following regex code; after the number, it detects the period, but not if there is a space between the number and the text.
(\d+|d+\s)\.\s*([0-9a-zA-Z].*?)\s+([0-9a-zA-Z]\..*?)(?=\d+\.\s*[0-9a-zA-Z]|$)
Test this is first string and random digits:15*893 A.TEST B. TEST2 52.Test this is second string A.TEST B. TEST2 53 . This is 3th string A.TEST B. TEST2 54. this is next string.. A.TEST B. TEST2
Part 53 does not detect. What is the reason of this?
https://regex101.com/r/MqBcB6/2
You just need to allow for spaces between the digits and . where you check for them (at the start of the regex and in the lookahead):
(\d+)\s*\.\s*([0-9a-zA-Z].*?)\s+([0-9a-zA-Z]\..*?)(?=\d+\s*\.\s*[0-9a-zA-Z]|$)
Demo on regex101

Regex to match letters and digits except 6 digit long number [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
Can someone tell me how to allow in Regex all a-zA-Z0-9 except 6 digits long number?
So true for:
1234567
a123456
123456P
3A237bdb8
but false for
123456
I want to
allow only letters and digits
deny 6 digit long number (like 123456) and other not letter characters like -_+,.!##$ etc.
If your regex engine supports lookahead, you can use:
^(?!\d{6}$)[a-zA-Z0-9]+$
Demo

Regular expression for numeric range from -a to b where a is not equal to b [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 5 years ago.
Improve this question
Let a and b be digits. The problem is easily solved if a=b, I can test the sign/no sign and then proceed to match the range of numbers from 0-a. I don't know how to solve this when the numbers are unequal.
How can I do it in python using a regular expression?
If you want for example between -7 and 4 :
(-[1-7]|[0-4])
Here is an example : https://regex101.com/r/8TnSVn/1

Regex to match 1 to 10 digit number with any number of decimal Places [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 a regex to match cost.
Valid cost-
1.1234455
12.434343
123.3333
..
upto 10 digits maximum..
and invalid is
0.545454
000.5435435
Here is a regex that will match any cost except those that have all zeros before the floating point
(?!0+\.)\d+\.\d+
http://regex101.com/r/pQ4kB3

how to write a regular expression for like ABCD1234? [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 8 years ago.
Improve this question
I want to set up a rule for a string:
8 chars
first 4 is alphabet, case insensitive.
last 4 is number
how to write a regular expression for this case?
^[a-zA-Z]{4}\d{4}$
Explanation:
^ start of string
[a-zA-Z] the characters a to z and A to Z
{4} repeat the list item 4 times
\d a digit character
{4} repeat the list item 4 times
$ end of string