Skip to content

Tag: string

How to make a Java containsignorecase that works with all human languages

For example I have this simple containsignorecase method: But it fails with some comparissions like: ΙΧΘΥΣ & ιχθυσ So I switched to this library which is mentioned here: which has its own method StringUtils.containsIgnoreCase: Now it works for ΙΧΘΥΣ & ιχθυσ, but it fails for weiß & WEISS, tschüß & TSCHÜSS, ᾲ στο διάολο & Ὰͅ Στο Διάολο, flour and

Retrieve word(s) from characters using map

I am trying to understand Collections and Stream. I have split the sentence below and kept the position of each letter (I ignored space/blank): “Hello Word!” Results: [H, e, l, l, o, , W, o, r, d, !] (charsList) {!=[10], r=[8], d=[9], e=[1], W=[6], H=[0], l=[2, 3], o=[4, 7]} (charsIndex) How can I sort the characters and rebuild my word

Regex for letters and numbers with any underscores in between

I’m trying to create a Regex String with the following rules The username is between 4 and 25 characters. It must start with a letter. It can only contain letters, numbers, and the underscore character. It cannot end with an underscore character. when it meets this criterion I want the output to be true otherwise false, but I only get

Shuffle a string via swapping content to different index

I have an assignment in which we are instructed to create a method which takes a string, scrambles the content of the string, and then returns the scrambled string (ie “Hello” returns “elloH”). However, we are only allowed to do this via loops and basic string functions (no arrays can be used). My Teacher has left the following suggestion for

Return string next to another inside a .txt file (JAVA)

I have a .txt file that reads for example: The idea is to create a function that receives a strinf and compares it to the first three characters, in this case, AAA, ZZZ or LKH, and if it is equal, it returns the numeric value, but my comparison isn’t working as intended, because the comparison doesn’t seem to be working

The longest Substring without Repeating Characters

I’m starting out on LeetCode, and am currently working on the problem Longest Substring Without Repeating Characters. Given a string s, find the length of the longest substring without repeating characters. Input: s = “abcabcbb” Output: 3 Explanation: The answer is “abc”, with the length of 3. I feel like my approach should work, but for some reason it fails