Questions tagged [replaceall]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
7
votes
1answer
650 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 ...
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 ...
2
votes
2answers
60 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 ...
2
votes
2answers
659 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 = ...
2
votes
1answer
113 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)*','') ...
1
vote
2answers
22 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 ...
1
vote
1answer
559 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(...
1
vote
1answer
233 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(...
0
votes
3answers
569 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
1answer
231 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
1answer
133 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 ...
0
votes
1answer
472 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
2answers
80 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. ...
0
votes
2answers
930 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. ...
0
votes
1answer
437 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 ...
0
votes
0answers
28 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
0answers
31 views

Regex Too Complicated when using ReplaceAll() Method in Apex…replaceAll('<!\\[CDATA\\[', '')

I am trying to use the ReplaceAll() method to replace these characters as given below in the string and add it to a htmlBody to send email to the Owners of those records in a batch class. String ...