Regular Expression to check first two user inputs and specific length [closed] - regex

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 7 years ago.
Improve this question
I have to validate user inputs which is numbers (8 digits), beginning with 77 and followed by any numbers.
e.g.
valid inputs
77123456
77281080
invalid inputs
17123456
1728080
All inputs should be followed by 77****** and 8 digits in total.
I tried this ^[0-9]{8}$, this validates the total number of digits to 8.

Try ^77\d{6}$. Two 7s followed by 6 digits. If \d doesn't work in your regex flavor, try ^77[0-9]{6}$

You can try this Regex:
"77\\d{6}"

Related

regex match only two group [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 6 months ago.
Improve this question
I want to receive in example regex match only 17 and 20 (skip 3 match only two match)
Depending on what you want to do, this one can be a good solution
[0-9]{2}(?!$)
It matches the groups of 2 digits not at the end of a line !
You can also try : ([0-9]{2})\s[A-z]+\s([0-9]{2}) if you want only 2 groups

Regex that allows one letter [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'm looking for regex extract that would pull what I need from the following strings please:
2/A 100 House
to result in : 2/A 100
7/X 7 Capital Flat
to result in : 7/X 7
0/H 98 Kale Road
to result in : 0/H 98
The numbers and letter after the / can be anything so needing something more generic. I'm not too familiar with regex and I've only managed to extract everything before first occurrence of a letter using (.*?)\[A-Za-z]
I need to keep the first occurence of a letter and the following space and number but want rid of every other letter after that.
I'm coding in SQL.
Thanks for any help you can give!
Looking at your example, I'm assuming both the first character and the last one before the text you want to remove will be a digits. And the first character after / will be a letter
\d+\/\w+\s+\d+
See demo: https://regex101.com/r/cLGvkm/1

Regex to select first two characters from string and remove rest of the string [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 4 years ago.
Improve this question
I want to select first two characters appearing on a given string like below.
in below example i would like the result to show "CJ" only.
";2;14;1;1;CJ;1;CT;1;DG;1;DJ;1;DT;1;QF;1;QG;1;QH;1;TA;1;TG;1;TK;1;TR;1;TW;1;TX";
([a-zA-Z]{2})
(): Capture the string into a group
[a-zA-Z]: Match any letter, upper or lower case
{2}: Match exactly 2 times
Make sure the "global" flag is not enabled ("global" allows returning multiple matches, not just the first)

What pattern should be used to validate 2 BIN MasterCard numbers [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 6 years ago.
Improve this question
"2" series BIN MasterCard numbers will start in October 2016. What regex pattern should be used to validate them. Today, we use the below pattern for MasterCards which start with 5:
var re = /^5[1-5]\d{2}-?\d{4}-?\d{4}-?\d{4}$/;
The answer by #Rawing incorrectly assumes that the BIN range of a MasterCard number will be changed to the new range while it is correct that the BIN range will be extended by the new range.
Therefore for future visitors that (blindly) copy the regex you should use this version to allow all "valid" MasterCard numbers (excluding luhn-check):
/^5[1-5]\d{2}-?\d{4}-?\d{4}-?\d{4}$|^2(?:2(?:2[1-9]|[3-9]\d)|[3-6]\d\d|7(?:[01]\d|20))-?\d{4}-?\d{4}-?\d{4}$/
Or this version without allowing dashes between the numbers:
/^5[1-5]\d{14}$|^2(?:2(?:2[1-9]|[3-9]\d)|[3-6]\d\d|7(?:[01]\d|20))\d{12}$/
This is basically a combination of #Rawings answer and the question.
I know this does not strictly answer the question but will hopefully prevent some copy-paste bugs in payment forms.
Extended Demo

Regex: Exact number of symbols and lines [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 7 years ago.
Improve this question
I would like to use regex in Java to substring text.
The string must be max 140 characters in all ( not counting new line/enter characters) and there might be max 4 lines
I found out how to substring 140 symbols: ^(.|\n|\r){0,140}
My question is how to add limitation for only 4 lines
and exclude new line/enter characters
Thanks for help!
This expression should do what you are looking for:
^([^\r\n]{0,140}(\r?\n|$)){4}
Try it here.