Questions tagged [apache-stringutils]

StringUtils is a class belonging to Apache Commons package. It offers utility methods for dealing with strings.

112 questions
0
votes
0 answers

How to use apache.commons.lang3.StringUtils.rightPad inside a JavaFX TextArea

I am using a TextArea in JavaFX to display a string that I drag into the TextArea. Inside the TextArea I want to keep a certain format. That's why I am using the rightPad function of the org.apache.commons.lang3.StringUtils library to format my…
Luk
  • 1,009
  • 2
  • 15
  • 33
0
votes
1 answer

String truncation in Java based on some conditions

My requirement is to truncate the string with max count and based on some conditions. The conditions are, The length of the string should not exceed the max count It should not end with half word like I want to trun The end of the string should be…
0
votes
1 answer

Django simple-apps template error - no StringUtil

I'm trying to use django basic apps from this site to make a basic blog work. It seemed to be going ok, but now the template keeps throwing an error saying "'stringutils' is not a valid tag library: Template library stringutils not found". Sure…
Alex S
  • 4,726
  • 7
  • 39
  • 67
0
votes
2 answers

StringUtils.replaceEach: Replace only separate words but not substring

I need to use Apache's StringUtils.replaceEach() method for replacing set of strings. However, this methods also replaces substrings in the word. I know I can use replaceAll method with \b regex. But I wanted to know if there's a way to tell…
funtik
  • 1,688
  • 3
  • 11
  • 27
0
votes
1 answer

How to manipulate a string in java in below scenario

"\r\n\r\n\r\n\r\nCovered. Coverage is limited to a one-time only 7095 for one outpatien" + "t in vitro fertilization procedure while you are an 7095 member.  If you receive" + " 7095s for in vitro fertilization services under an 7095 plan, you will…
user5982569
0
votes
3 answers

Get text between two tags using substringBetween() method of StringUtils

I have an input like:
280 Flinders Mall PROPERTY
IT Park office…
Richa Sharma
  • 75
  • 1
  • 9
0
votes
5 answers

Any Commons all substrings function?

I'm wondering if there's a library function (or why StringUtils in Apache Commons doesn't have it?) that for a String calculates all the substrings. For "abcde" it retuns "a", "ab", "b", "abc", "bc", "c", "abcd", "bcd", "cd","d", "abcde", "bcde",…
simpatico
  • 10,709
  • 20
  • 81
  • 126
0
votes
2 answers

Separate list items by whitespace and higher level metrics by tabs

I have the following functions: public String tabSerializer(String log, String time) { StringJoiner joiner = new StringJoiner("\t"); addValue(company, joiner); addValue(users, joiner); ... return…
Tee Jay
  • 103
  • 1
  • 1
  • 14
0
votes
0 answers

StringUtils StripAccents replaces accented letters with question marks

I'm trying to use Apache StringUtils stripAccents() method to remove accents from characters, and isntead of doing that it outputs question marks in place of accented letters. Example: Ádám is converted to ?dam instead of Adam. I'm using Scala…
Ia Rigby
  • 41
  • 1
0
votes
2 answers

Why can’t StringUtils.join accept a StringCharacterIterator?

The following code should work, since join accepts an iterator as argument: import static org.apache.commons.lang.StringUtils.join; import java.text.StringCharacterIterator; … join(new StringCharacterIterator("A String"), " "); Alas, it doesn’t.…
flying sheep
  • 8,475
  • 5
  • 56
  • 73
0
votes
1 answer

Would a forward slash cause issues with StringUtils.remove and .removeEnd?

I'm extracting a piece of text from a webpage using JSoup and cleaning up the resulting string with Apache's StringUtils library. The first pass, using substringBetween to grab just the text in parentheses works like a charm, returning a string…
katman
  • 3
  • 2
0
votes
1 answer

Escape both HTML and JSON

Is there a recommended way to escape both HTML and JSON? Currently I'm using StringEscapeUtils from Apache Commons Lang. Before putting data into my database, I first forward the input String to a method which first escapes the HTML and then escapes…
Robin
  • 177
  • 1
  • 9
0
votes
2 answers

String Utils join in not working as expected

I have a list of strings which is returned from a query in List A. I am trying to use String Utils.join to combine the values in the list to a string separated by comma and in quotes. But it is not working as expected. Values in abcList - [abc, cde,…
user6591323
  • 69
  • 2
  • 11
0
votes
1 answer

Replace different combinations of whitespaces, tabs and carriage returns with a single white space

I would likwe to replace different combinations of whitespaces, tabs and carriage returns with a single white space. So far i got a solution that works: String stringValue=""; stringValue = stringValue.replaceAll(";", ","); stringValue =…
Douy789
  • 1,015
  • 10
  • 16
0
votes
2 answers

Java Is there a feature for replacing placeholders inside a String with a String variable

I have a requirement to move all the hard-coded error logs to DB. Some of the error logs comes in the format "xxxxx" + variable + "xxxxxx"; It is not possible to change the structure of the table. Neither can I do some String insert based on the…
NixRam
  • 509
  • 1
  • 10
  • 21