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
Related
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 months ago.
This post was edited and submitted for review 7 months ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I need to make a pattern matching RSA modulus (n) which looks like this:
01sjBnlcardSsWRiEm9i4hZCn0iz12HypdP_1osRvD4O6__tl0qRlE9t1afTXzLDrFaySdQOVd8LGQWi1RixCnb01-7ypxvPDM4yM02haCgD5an9CUSulWUtsiUi01UCgvOYsKEfSBoDVx875G7ypUJx4SN7WnlIDJI2-fWkPwx-hVcDyP6Uzrf9vTsQrzZYAEkIjFcveG_6zwnQtj5K1fIJteZoLeNsTiGwSVJkg6QUkbfVgv5edjE9NTr8Z6jlfJR0q_N9mt3qzRh85ovTNLWoqN99Nbv_t5fq7he6fgM6mnT6PPfaR9auMvtv9kI_659NFKT7BXMD3nV3SjtkSuJFByeiSc5kjrbCGaZB5wgZghYKoQEImrVEotuOXBLVF3-Cw_Jzgcsi7cUfdEH98Ro8_uVJGDMBu0Dbd36d724S-42eh2t9qHor0WosSbCIkuKLVZiiyChRWQk9GelhQ3mSRXmyfVukfMlMpyR0Y3oT4OgQiVtPvONA11PySJpUBItd4xk5tobKE0LaG83bf85syq4PY_jBGVW8Dy-nAmJKcAQ-5UJkNlgzeUK_qbCzjZxrbPwnGm7Pl258a58FtCdFnJYNQjleCE_2YhXX-9iWBS_FycABUdM_tBk0m5NYOZ5JSvx8eQOxUmt7iISa0o24Pu1PNpB2EpANN7KPVZM
or one more example
4VUYy3BrKtcxndUwdAtBE-rqoxVcnceCd2vxvyDxgbNboGGC5cLBion6sM9aAWa1FLCIebN9dgXVnZokzS5KVtRO4BqUAo7u_8yBblSg_PyKqCNao_XGxHaclkuXm5_vFhRNxzk6sA54S2EWOB84Cj7z3EfZaEO2-YGJ7Nkso5ig4IExLnIco688iGTx3EX7sPpGwEfQebMOfDEtmPHpVkJhznad5IzlhEFjZY5tDDZPEIL6jeFbLAoFA6xy9FEp2xt3TDwa_w9cIqGnUVndUzfjXFykRREW88eMMqxuJYeQEAh3pw-huKlCWk78GxO1xoYaVMVeQyYp0r3Pz-FIvPs78KI2pkiT7zmx8viC46Mve2_FYymTGiK1XesoSwqIoANjCeJJV3wEV67nKb5j9uG4Mlhtta5aDbSkV4rYsJbG-A0Tcc5vSEJBwGDeZ_l7McbuWk31vaQcEWoGB3Ktc9Qnl-z4i_N__QcZ7ZEEg2nB797keEHpmuhqqgkUkoetBCxb15_Vfp85j6upACglIodTz60fjf8tZ2gQUwITHNFk2IAX3vcoJuNSblfZwXo-a5FFnY_mcbHmstXuvPu-9ZCC0-UsHX6LTPrt_IJUhKdnLKnvTEWII78VirWcpoYzOBK2EFIs64ELCYnM0szv-Qp4Zcurparp7nkqMpy2O1c
Needed to find it in text like
kty: "RSA",
n: "01sjBnlcardSsWRiEm9i4hZCn0iz12HypdP_1osR..."
or
<n>01sjBnlcardSsWRiEm9i4hZCn0iz12HypdP_1osR...</n>
and so on.
I tried \S{683} but it's too large sample so I need exclude repetition of characters and have their mandatory diversity to escape matching with "aaaaaaaaaa..." or "0000000000..."
Please help if someone has it. Thanks!
If you want to match only when the entire string is exactly 683 characters and contains only valid base64 characters, use:
^[a-zA-Z0-9_\-=]{683}$
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 2 years ago.
Improve this question
The program contains text of this type:
A B Ccccc
A Ccccc
ACcccc
ABCcccc
I need only such text to remain:
Ccccc
I wrote a replacement function, but I just can’t pick up a pattern
How to make such a pattern?
No need for regex, nor VBA. It seems you simply are looking for the position of the last upper-case letter and then to extract from there:
Formula in B1 (with Excel O365):
=MID(A1,MAX(SEQUENCE(LEN(A1))*(EXACT(UPPER(MID(A1,SEQUENCE(LEN(A1)),1)),MID(A1,SEQUENCE(LEN(A1)),1)))),LEN(A1))
If you don't have Excel O365:
=MID(A1,MAX(ROW(A1:INDEX(A:A,LEN(A1)))*(EXACT(UPPER(MID(A1,ROW(A1:INDEX(A:A,LEN(A1))),1)),MID(A1,ROW(A1:INDEX(A:A,LEN(A1))),1)))),LEN(A1))
You probably need to enter as array through: CtrlShiftEnter
If you must go through VBA and regex then a pattern like:
[A-Z][^A-Z]*$
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 5 years ago.
Improve this question
I am trying to filter medical words from general english words.
but most of the drugs name contains hypen in it.
pls suggest how to check in python, that a string contains only alphabets and hypen.
for example : anti-allergic
Simplest way to check string is as below, remove '-' from string and check if remaining characters are all alphabets.
test_str = 'anti-allergic'
if test_str.replace('-','').isalpha():
print('Valid string')
This can be accomplished by using regular expressions (https://docs.python.org/3/library/re.html), where a (very quick and dirty) regex could ask for all letters, a to z (and A to Z), that has a hyphen in it.
([a-zA-Z]+[-].+)
Would match the following:
suoad
ADDADA
waeewrw
omaeqweSADADSwu
iraaief
anti-allergic
ANTI-ALLERGIC
testtesttest
You can test this out yourself using https://pythex.org/.
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}"
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 9 years ago.
Improve this question
I would use regex to select one changing number
For example in the following example I would select 12090343 that I could change
I use:
preg_match (/(?<=Dossier.N..)(.*)(?=-)/)
It works but it's not so clean I think because the number of spaces could change and so it will not detect the number any more
Dossier N° 11110144-001 Pvt du : 03/09/2013 à 7:16
It looks fine, but you could slightly clean it up by .not grouping the number and making it match digits:
(?<=Dossier.{0,3}N.{0,3})\d+(?=-)
Most regex engines can't handle look behinds of arbitrary length, so rather than using the simpler (but unbounded) expression \s*, you must use a limited length expression like \s{0,3} to allow "some" whitespace.
You can try the following expression:
/Dossier[^0-9]*\K([0-9]*)(?=-)/
Regex101 Demo