RSA modulus N regular expression [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 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}$

Related

Regex pattern to replace characters [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 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]*$

how to get string between two dots in ansible [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
this is part of my ansible hosts files:
[Arista]
Ars-898z.cnd0 arista_host=Ars-898z.cnd0.example.com
Ars-898y.mex0 arista_host=Ars-898y.mex0.exmaple.com
I want to somehow use filtering or regex to extract only cnd or mex (the string between first and second dot) in my ansible playbook and save it a variable such as "dcname" and use it create a folder.
Please let me know how I can do it. I have already searched stackoverflow but did not get any similar questions for ansible
How about this?
(?<=\.)[^.]+(?=\.[^.]*\.[^.]*$)
Regex101 demo.
Here is a more flexible solution:
(?<=\.)[^.]+(?=(?:\.[^.]*){3}$)
The 3 can be adjusted. It is the number of dots '.' that come after the matched substring. If you enter 2, you get "cnd0", if you enter 3, you get "cnd0 arista_host=Ars-898z".
Another demo.

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.

i want to parse a string between two -'s by using regexp [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 parse the values between -. but for some data like 1st url contains -- so in that case i need to get the gap only and the next one i am able to get **camry** successfully by using *(site_data,'[^-]+',1,2)*. but i want to handle the gap as well.
U=Google--undefined|http://www.google.com/urlsa=t&rct=j&q=&esrc=s&frm=1&source=web&cd=2&ved=0CFMQFjAB&url=http://www.toyota.com/tundra/features.html&ei=-zwQUvOyGIXu2QWC7oGgBg&usg=AFQjCNFQKGcr2dbDeC-0zagtYdKFEfXXzQ&bvm=bv.50768961,d.aWc
U=Bing-camry-undefined|http://www.bing.com/searchq=camry&pc=MOZI&form=MOZSBR
Please help on this.
You can extract the string along with the hyphens, and then trim the hyphens.
trim('-' from regexp_substr(site_data,'-[^-]*-'))
Alternatively, you can also use regexp_replace function.
regexp_replace(site_data,'(-([^-]*)-)|(.)','\2')