Questions tagged [replaceall]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
121 views

Write an invocable apex class to remove characters from a string

Fairly new to Apex so please bear with. I am trying to write a simple Apex Class that makes use of the replaceAll function to remove unnecessary characters from a string. I've got as far as the ...
Matt Stone's user avatar
0 votes
1 answer
478 views

Apex replace \" in string

String jsonString = 'Error \"fatal\"'; String jsonString2 = jsonString.replaceAll('\\"', ''); System.assertEquals(jsonString, 'Error fatal', 'Assertion failed'); The jsonString ...
dev4life's user avatar
  • 510
-1 votes
1 answer
1k views

Replace String inside json inside Array Javascript

Hello guys I have a js file that has a list of json that have the next structure: [{"label":"9312 - Item1", "value":"9312"}, {"label":"9313 -...
TechGuy's user avatar
  • 97
0 votes
2 answers
307 views

Replace '{}' in Apex

Hello everybody I am passing a Json from javascript to an Apex controller to validate some info. The problem is that the json comes with some values like this: "Direction": {} And I want to ...
TechGuy's user avatar
  • 97
0 votes
1 answer
711 views

Regex to find dd/mm/yyyy

I have a pretty simple code and in one case it works, and not in all the case, I wanted to know what I'm missing I'm trying to match a date in this format dd/mm/yyyy This is my code: String d = '20/03/...
Yaac0's user avatar
  • 165
0 votes
2 answers
6k views

Removing leading zeroes in Date String

I have checked a number of posts and regex examples but for some reason I can't get the leading 0's to be removed from the date string below. Can anyone see what I am doing wrong? wanted result: 4/6/...
Olivia's user avatar
  • 3,461
1 vote
1 answer
1k views

Handling special character in apex

I have one import object which stores the record from data loader then I run my apex class which pick the record from import object and assign data to the respective fields in new object. When I try ...
sfdc developer's user avatar
4 votes
1 answer
3k 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: ...
jdrees's user avatar
  • 207
0 votes
0 answers
1k 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 ...
626's user avatar
  • 273
1 vote
1 answer
2k 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 ...
Shobhit Saxena's user avatar
1 vote
2 answers
61 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 ...
isherwood's user avatar
  • 444
2 votes
1 answer
11k 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(&...
Jay's user avatar
  • 55
0 votes
4 answers
6k 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\'...
Sisir's user avatar
  • 111
0 votes
2 answers
506 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. ...
Miguel Gaurano Punzal's user avatar
2 votes
1 answer
941 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(...
Loren's user avatar
  • 84
1 vote
1 answer
2k 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(...
AverageJoeVBA's user avatar
2 votes
1 answer
168 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)*','') ...
user45612's user avatar
0 votes
1 answer
382 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?
Testing_SFDC's user avatar
  • 2,940
0 votes
2 answers
2k 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. ...
qarthandso's user avatar
2 votes
2 answers
75 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 ...
Amulya's user avatar
  • 367
0 votes
1 answer
705 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 ...
Testing_SFDC's user avatar
  • 2,940
2 votes
2 answers
737 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 = ...
Anu's user avatar
  • 3,847
4 votes
1 answer
3k 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 ...
Anu's user avatar
  • 3,847
7 votes
1 answer
689 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 ...
brovasi's user avatar
  • 5,655