replaceall Questions
3
Solved
I want to replace all the occurrences of a group in a string.
String test = "###,##.##0.0########";
System.out.println(test);
test = test.replaceAll("\\.0(#)", "0");
System.out.println(test);
Th...
Cloudlet asked 26/5, 2015 at 9:50
1
Solved
What's the difference between replaceAll("\\s+") and replaceAll("\\\\s+")? Usually I use \\s+ but sometimes I see \\\\s+.
Filagree asked 27/11, 2014 at 14:11
7
Solved
This has been asked several times for several languages but I can't get it to work.
I have a string like this
String str = "This is a string.\nThis is a long string.";
And I'm trying to replace ...
Bowne asked 16/6, 2010 at 20:12
2
Solved
I want to create a program that gives the number of characters, words, etc... in a user-inputted string. To get the word count I need to remove all the periods and commas form a string. So fa...
Furr asked 31/12, 2013 at 18:51
7
Solved
I have really weird error in my java code and can not figure out what is wrong.
Let's say I have this code:
private void test()
{
String test1 = replace("1.25");
String test2 = replace("1.5");
...
Mandatory asked 19/12, 2013 at 15:55
4
Solved
I have a string like this: John \n Barber now I want to replace \n with actual new line character so it will become
John
Barber
this is my code for this
replaceAll("\\n", "\n");
but it is no...
Astrophotography asked 18/9, 2013 at 6:36
3
So to remove all the spaces in my string. I did a method that is consists of
message = message.replaceAll("\\s", "");
I was wondering if there was a command to remove and special character...
Precentor asked 3/9, 2013 at 18:21
2
Solved
Is there a library or any easy way to convert a string and make sure its compatible as a regex to look for and replace in another string. So if the string is "$money" it would get converted t...
Packaging asked 20/6, 2013 at 22:48
3
I am looking to replace a java string value as follows. below code is not working.
cleanInst.replaceAll("[<i>]", "");
cleanInst.replaceAll("[</i>]", "");
cleanInst.replaceAll("[//]"...
Suboxide asked 31/5, 2013 at 21:12
2
Solved
Possible Duplicate:
String.replaceAll() anomaly with greedy quantifiers in regex
I was writing code that uses Matcher#replaceAll and found following result highly confusing:
Patter...
Insulin asked 24/1, 2013 at 23:4
2
Solved
The following code uses the replace() method of the String class in Java.
String a = "abc/xyz";
System.out.println(a.replace("/", "\\"));
/ in the given String a is being replaced with \.
The s...
Parmer asked 17/10, 2012 at 18:52
9
Solved
How to replace all "(" and ")" in a string with a fullstop, in Java? I tried in the following way:
String url = "https://bitbucket.org/neeraj_r/url-shortner)";
url.replaceAll(")", ".");
url.replac...
Anklet asked 12/9, 2012 at 8:10
5
Solved
Hi I want to know what is the time complexity of the "replaceAll" function of the String class but I can't find any information on it.(http://docs.oracle.com/javase/6/docs/api/java/lang/String.html...
Apocarp asked 10/4, 2012 at 15:36
4
Solved
I'm trying to replace a substring that contains the char "$". I'd be glad to hear why it didnt works that way, and how it would work.
Thanks,
user_unknown
public class replaceall {
public static...
Jolley asked 5/11, 2010 at 12:30
3
Solved
I have a string and when I try to run the replaceAll method, I am getting this strange error:
String str = "something { } , op";
str = str.replaceAll("o", "\n"); // it works fine
str = str.replac...
Smutty asked 13/12, 2011 at 14:47
3
Solved
I have this unit test:
public void testDeEscapeResponse() {
final String[] inputs = new String[] {"peque\\\\u0f1o", "peque\\u0f1o"};
final String[] expected = new String[] {"peque\\u0f1o", "pequ...
Breaststroke asked 14/6, 2011 at 19:19
4
Solved
I tried this code:
string.replaceAll("\\(.*?)","");
But it returns null. What am I missing?
Keratin asked 12/4, 2011 at 13:34
2
Solved
I'm looking to figure out the answer to this problem here.
First off,
blah[abc] = blah[abc].replaceAll("(.*) (.*)", "$2, $1");
Can someone explain to me what the (.*), $2 and $1 are?
Secondly,...
Windowshop asked 4/3, 2011 at 3:45
3
Solved
I have a problem with the replaceAll for a multiline string:
String regex = "\\s*/\\*.*\\*/";
String testWorks = " /** this should be replaced **/ just text";
String testIllegal = " /** this shoul...
Griffon asked 11/11, 2010 at 12:10
3
Solved
<?php
$str = "word <a href=\"word\">word</word>word word";
$str = preg_replace("/word(?!([^<]+)?>)/i","repl",$str);
echo $str;
# repl <word word="word">repl</word&...
Glaucescent asked 22/7, 2010 at 0:27
4
I have the string "MO""RET" gets stored in items[1] array after the split command. After it get's stored I do a replaceall on this string and it replaces all the double quotes.
But I want it to be ...
Quaggy asked 11/2, 2010 at 2:48
© 2022 - 2024 — McMap. All rights reserved.