Questions tagged [replaceall]
The replaceall tag has no usage guidance.
17
questions
2
votes
1answer
39 views
Using String.replaceAll() to remove character combination
I need to remove all redundant hyphens in a given string, e.g.: "Bla----Bla---Bla--Bla" to "Bla-Bla-Bla-Bla", using as little code as possible.
At the moment I've implemented this:
...
0
votes
0answers
269 views
Error escaping double quotes in large JSON string in Apex
I have large JSON response that I am trying to escape all instances of strings that are problematic for deserialization but am having some issues.
Using .replaceAll works but that throws a "Regex too ...
0
votes
1answer
347 views
String.replaceAll not able to replace String escape character
While making an API Call, my json String is containing \, which I want to remove. But I am not able to do so, by using the replaceAll method of String class. Can anyone please help?
The json request ...
1
vote
2answers
28 views
Why can't I apply replaceAll in my controller function?
I have the following component class, whose function is solely to modify a string for an email template. It works fine, inserting the concatenated string into the email.
public class ...
0
votes
1answer
1k views
Replace single quotes
I need to replace single quotes. However, I cannot use the "
double quote character. Therefore, I cannot do something like this:
String s = "Hello 'thanks' bye";
s = s.replaceAll("'", "\\'");
...
0
votes
4answers
2k views
replace ' with \' in apex code
i have string variable called "Identifier" which has apostrophe in it.
example: Identifier = "string's length"
i need to replace this apostrophe with "\'"
the result should be Identifier = "string\'...
0
votes
2answers
139 views
Replace + Sign by Underscore
Trying to replace a character '+' with underscore.
Tried:
String s = 'Happy+Me';
System.debug(s.replaceAll('\\+', '_');
System.debug(s.replaceAll('/\[+]', '_');
Still gives me 'Happy+Me' result. ...
2
votes
1answer
337 views
String Class normalizeSpace() and replaceAll() doesn't work with the Rich text area field
Does anybody know why the normalizeSpace() or replaceAll() doesn't work with my rich text area field? I tried entering same value that I have on the rich text area and manually adding it on a variable(...
1
vote
1answer
925 views
Replace String with Wildcard
Is it possible to replaceall on a string using wildcards?
For example
string adder;
adder = '[Test | 123 ! xyz]';
string replaced;
replaced = adder.replaceall('|%!','');
System.AssertEquals(...
2
votes
1answer
132 views
Regex does not work on incoming mail
I'm trying to delete gmail history before creating a case comment.
The line of code causing the problem seems to be
.replaceAll('On\\s.+\\sat\\s.+\\s<\\s*\\r*.+@.+>\\swrote:(.|\\n|\\r)*','')
...
0
votes
1answer
290 views
Replace double character with single in string
I have to replace double semicolon (;;) in a string with single comma(,) in an apex class. Can someone help me?
0
votes
2answers
1k views
Simple APEX String Replacement - can't unencode quotation marks
I've tried quite a few different methods to unencode a simple string but nothing's turning up.
That's the end of my API call, using a regex solution I found online, although it's not working out.
...
2
votes
2answers
61 views
Replaceall() function working weird
I have a requirement where I need to format 'Phone Number' field which is of type 'Phone'. It should not allow some of the special characters like %$#@*&, so am trying to replace each character ...
0
votes
1answer
480 views
Translate spanish characters to english for field values
I have a requirement to translate few predetermined spanish characters to english in field values of different custom objects. I have tried to create a generic code. can someone please let me know ...
2
votes
2answers
669 views
Issue with the string.replace method in salesforce
I have a string (1 and 2) Or (3 and 4) the format of the () can be changed because it is auto generated in the filter of the reports. and i do have four conditions that
1) Age = '60'
2) FirstName = ...
4
votes
1answer
2k views
How to remove ( from the string
I have a string value where I am getting the a integer with ')' I want to remove the ')' have the value separated from all the unwanted special characters. Do any one here have any idea how can I ...
7
votes
1answer
655 views
How to replace 'MyFirstName' by 'My First Name'
Is there any easy way, by using regex and replaceAll method, to tranform MyFirstName by My First Name. I know I could loop through each character but I was wondering if it was possible to do that in ...