I know that there are different ways to solve this task, but I need a particular way using replaceAll() method. I just stuck with right condition in the expression. So I have a method like this: The case is next: I pass to the method some comments and max length of comment. The method should take list of comments and
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
using tfilelist or tfiledelimited how can i iterate through a list of columnA, column B combination and store in tjava to use for tdbinput
I have a talend job that i am trying to read the columns from the csv file sequentially row by row for each combination (if possible trying to collect unique combination) of COLUMN A & COLUMN B to get the values and store in tjava (context variables to reuse and query the tdbinput) CSV in the below format: OPTION 1:
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
Count the Characters in a String Recursively & treat “eu” as a Single Character
I am new to Java, and I’m trying to figure out how to count Characters in the given string and threat a combination of two characters “eu” as a single character, and still count all other characters as one character. And I want to do that using recursion. Consider the following example. Input: Desired output: Current output: I’ve been trying
Regex for finding only single alphabets in a string and ignore consecutive double
I have searched a lot but I am unable to find a regex that could select only single alphabets and double them while those alphabets which are already double, should remain untouched. I tried But since this (\w)\1+ selects all double elements, my output becomes yahoooo. I tried to add negation to it !(\w)\1+ but didn’t work and output becomes
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