Finding Patterns Has Never Been Easy — Until Now!

Finding Patterns In A String — Java

An Easy Way To Know How Much A Pattern Has Been Repeating!

JumperBot_
2 min readAug 6, 2022
A Picture Full Of Vibrantly Colored Patterns!
Photo by George Pagan III on Unsplash

Have you experienced typing out a String and wondering how you could compress it into even smaller chunks using a compression algorithm that uses a Binary Search Tree or anything else that requires you to find patterns? Or maybe you just got bored and wondered:

How Many Times Have I Been Repeating Myself Lately?
— Probably You Just 2 mins. Ago Contacting Somebody…

Well then, I’ve got a utility just for you! (~And probably somebody else too!)

  • You can find it → OVER HERE! ← along with my other utilities!
  • The use of it is incredibly simple, let’s try it out with a simple program!
Code Used As A Simple Program!
  • This prints out every single 1 character long pattern in the String:
[D, 1], [o, 9], [ , 18], [Y, 1], [u, 2], [K, 1], [n, 3], [w, 1],
[T, 4], [h, 4], [a, 8], [t, 6], [I, 1], [H, 1], [v, 3], [e, 11],
[A, 1], [G, 1], [i, 4], [b, 1], [R, 1], [p, 1], [s, 4], [r, 6],
[y, 1], [C, 3], [l, 4], [d, 2], [J, 1], [-, 1], [S, 1], [m, 3],
[U, 1], [?, 1], [P, 1], [F, 2], [O, 1], [!, 1]

But What About Filtering Everything That Only Happens Once?
— Probably You Again, I Guess.

  • That’s why we have the #removeOnes() function!
Code Used As A Simple Program!
  • This prints out every single 1 character long pattern that occurs more than once in the String:
[o, 9], [ , 18], [u, 2], [n, 3], [T, 4], [h, 4], [a, 8], [t, 6],
[v, 3], [e, 11], [i, 4], [s, 4], [r, 6], [C, 3], [l, 4], [d, 2],
[m, 3], [F, 2]

But What Abou~
— Probably You Stopped By Me This Time Around.

  • Woah, hold your horses buddy, you can get any pattern with any length!
  • All you have to do is tell it the length of the pattern that you need to see:
Code Used As A Simple Program!
  • You could continue this until you get exhausted!

The class is permissively licensed under the MIT License.

In other words, do whatever you want to do with it as long as you include a copy of my license! Don’t forget to fork and star my repository as a quick “Thank You!” to me (as the maintainer) and to the future contributors!

Want to see me procrastinate but most importantly code?
Go and find out if you’d like My YouTube Channel then!

Want to read another article?
Read — Regex-Patterns-Made-Easy — by yours truly.

--

--

JumperBot_

Hey-ya, I develop Android apps , Websites and some CLIs for fun like anyone else out there.