StringUtils is a class belonging to Apache Commons package. It offers utility methods for dealing with strings.
Questions tagged [apache-stringutils]
112 questions
1
vote
1 answer
substringBetween() returns null when trying to extract ..
I am building a small Java application to fetch five Wikipedia pages and find substrings in the html source code. I am using the library org.apache.commons.lang3.StringUtils. However a Wikipedia article can be big, and there seems to be a limitation…

trakmack
- 93
- 7
1
vote
3 answers
StringUtils splits based on regex
I have a following code to split my input String:
import org.apache.commons.lang.StringUtils;
public class SplitTest {
public static void main(String args[]) {
String input = "A||B||||D||E";
String result[] =…

Chandra Prakash
- 781
- 4
- 13
- 23
1
vote
2 answers
Newline escape sequence not unescaping in proper way in Java
I am fetching a String from SQL server 2008 database into my Java code and trying to print it. Unfortunately the newline escape sequence is not automatically converted into newline.
I know the reason is we are not putting the string inside the…

sunny_dev
- 765
- 3
- 15
- 34
1
vote
1 answer
Extract string using StringUtils
Let's take a string "aabaabaa" and I want to know the position of "aa" in middle or from last.
For example position of "aa" from right should be : 6 (taking start insex as 0)

Sumit Sahoo
- 2,949
- 1
- 25
- 37
1
vote
1 answer
Search function Not Working
I have a text Field where the user enter a world to search a JTable when the user click a button called btnSearch.
every time I try to perform a search nothing happen and an Exception is thrown (see error below) when debug it show that the error…

Sarah
- 133
- 1
- 9
1
vote
1 answer
How to pass the text with spaces and parenthesis to java
I am passing a value as request attribute to the jsp page.
request.setAttribute("description", StringEscapeUtils.escapeHtml("Hello 1F World (Hello World) Hello World"));
In jsp Page I am setting in the pageContext
String text = (String) (String)…

user525146
- 3,918
- 14
- 60
- 103
1
vote
2 answers
Android+Ant external jar library
I'd like to try org.apache.commons.lang.StringUtils in my Android project. I have downloaded commons-lang3-3.1.jar and placed it in my project's libs directory. However importing it fails with the library not being found. I have used many variations…

Jocala
- 243
- 1
- 4
- 16
1
vote
2 answers
What is the most efficient way to check if a string is part of a bigger string?
I have a string which is formed by concatenation of IP addresses, for example:
"127.272.1.43;27.27.1.43;127.127.27.67;128.27.1.43;127.20.1.43;111.27.1.43;127.27.1.43;"
When a new IP address is given, I need to check if the first half of the IP is…

Darshan N Reddy
- 229
- 2
- 10
0
votes
3 answers
Increment counter and display as zero padded string in Java
Are there any existing utilities like Apache Commons StringUtils that make it easy to increment an integer, but output it as a zero padded string?
I can certainly write my own utilizing something like String.format("%05d", counter), but I'm…

Tauren
- 26,795
- 42
- 131
- 167
0
votes
4 answers
To remove last two words from a string
I have sample strings like below,
abc/def/ghi/test/yvw/syz
abc/fed/igh/test_123/wuvacv/zyxh
I want to get it like below
abc/def/ghi/test
abc/fed/igh/test_123
So what are the best way to follow for string manipulation
Thanks in advance.
I'm trying to…

Saduni Jayalath
- 9
- 2
0
votes
2 answers
Apache Commons StringUtils.join creating strange square brackets, commas and whitespacing in output
Java 11 here. I am trying to use org.apache.commons.lang3.StringUtils.join to take a list of strings and join/concatenate them into a single string, separated by an @ sign. If there is only one (1) string in the list, then the joins/concatenated…

simplezarg
- 168
- 1
- 9
0
votes
1 answer
StringUtils not found in Eclipse (java.lang.NoClassDefFoundError), although referenced as a library
I want to filtrate website content that I have stored in a String with StringUtils.
Got some problems with the libraries.
Java-code:
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import org.apache.commons.lang3.*;
public…

Dorian Feyerer
- 258
- 5
- 14
0
votes
0 answers
Finding a Nullness annotation compatible with org.apache.commons.lang3.StringUtils
I am trying to find the right combination of nullness annotations and nullness checking functions in my project. I deal with a lot of String variables that have the possibility of being null, and need to check in a lot of places whether these…

Casey Daly
- 383
- 8
- 25
0
votes
3 answers
Regex to split a string based on \r characters not a carriage return or a new line
i want a Regex expression to split a string based on \r characters not a carriage return or a new line.
Below is the sample string i have.
MSH|^~\&|1100|CB|CERASP|TESTSB8F|202008041554||ORU|1361|P|2.2\rPID|1|833944|21796920320|8276975
i want this…

suri
- 41
- 1
- 2
0
votes
1 answer
isAlpha(str) is method converting Persian into Unicode characters and return true
I am trying to get data only in English language.
I tried different methods like:
public static boolean isAlpha(String s){
return s != null && s.matches("^[a-zA-Z]*$");
}
Or StringUtils as:
public static boolean isAlpha(String str){
return…

User169
- 81
- 7