If the point is to generate all possible strings that could be passwords, given that they all include a contiguous "hint" as a substring, then this would be very easy to do, but I don't think a regex match/substitution would have anything to do with a suitable brute-force answer.
Given that you know the set of characters allowed as part of the password, then I suspect that some nested-loop approach (having those characters in an array) would probably constitute the expected solution.
That said, I'm sure it would be easier in perl than in java. For example, if the password length is N and the length of the "hint" substring is M, you could loop over all possible character sequences of length N-M, and for each of those, insert the hint string at each juncture within the sequence (offset 0, offset 1, ... offset N-M).
(Update: in other words, what Zaxo said :)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.