Skip to main content

Questions tagged [string]

In computer programming, a string is traditionally a sequence of characters, either as a literal constant or as some kind of variable. In Apex it is considered as any set of characters surrounded by single quotes.

Filter by
Sorted by
Tagged with
9 votes
1 answer
8k views

Catch Regex too complicated when splitting a string in salesforce

I have created a function wherein I split a string from the csv filecsvAsString.split('\n') . It is working when the string is not so big. But when I try to split a very large string, an error will ...
Hope's user avatar
  • 1,273
8 votes
3 answers
55k views

JSON and escaped double quote

I'm currently making a callout to a 3rd party vendor and I'm getting a huge response. What is currently messing me up is this section: "MessageSeq":13,"Description":"config ...
Double A's user avatar
  • 2,133
6 votes
1 answer
2k views

Regex: Make Dot Match Newline?

I use Rubular to test my regular expressions, when I need them. I am having a bit of trouble crafting an expression that will work for me. For reference, I am trying to match multiple substrings in ...
Adrian Larson's user avatar
  • 151k
18 votes
3 answers
8k views

Eliminating Unicode accents in Apex

Is there a published way to take text that may have accent marks and remove the accent marks? For example: System.assertEquals('Hello', transform('Ḧéļḻṏ')); I believe there is an equivalent method ...
Charles Koppelman's user avatar
50 votes
5 answers
178k views

How to check in Apex if a Text field is blank

I'm unsure what's the shortest and most robust way to check whether a Text field is blank / empty? /*1*/ Boolean isBlank = record.txt_Field__c == ''; /*2*/ Boolean isBlank = record.txt_Field__c == ...
Robert Sösemann's user avatar
8 votes
2 answers
10k views

Regex Help- Escaping Characters And Matcher Method

I have a string: allPunctuation = '~!@#$%^*()_+|}{":?><`=;/.,][-\'\\'; This string contains APEX's way of escaping characters so I can include the ' and the \ characters. When I pass this ...
Olivia's user avatar
  • 3,471
4 votes
1 answer
3k views

Using single quote by curly braces in String.format in Dynamic SOQL

I'm struggling to use String.format to replace a token with a value when the token is within single quotes: Example: String query = String.format('SELECT Id FROM Availability WHERE Person__c = \'{0}\...
Robs's user avatar
  • 9,416
4 votes
3 answers
7k views

Formatting Negative Numbers with Parentheses

Formatting numbers on a VF page, but I do a bunch of processing the Apex Class, so I would rather return the formatted String value from the controller. I am doing something like this, but I just ...
BritishBoyinDC's user avatar
3 votes
1 answer
2k views

Strings concatenation and one character size

Short prestory. Typical problem: you have a lot of small string and you want to concatenate them all in one big string. The code like for(Integer i = 0; i < smallStringsSize; i++){ bigString += ...
Bogdan Protsenko's user avatar
1 vote
1 answer
3k views

Escape backslash

I'm trying to define a string with the following value string s = 'Something\Something'; but I got Illegal character sequence '\S' in string literal. I tried escaping the backlash with another ...
MikeFerrer's user avatar
0 votes
1 answer
735 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,950
20 votes
1 answer
34k views

String length exceeds maximum: 6000000

Are there any work arounds for this issue? I'm trying to upload a file(attachment) to an 3rd party REST API Service. It works fine until my file sizes get about ~5 mb. Then I start getting the ...
NSjonas's user avatar
  • 10.2k
15 votes
1 answer
28k views

RestRequest RequestBody instead of Params

I am leveraging a webhook from a third party API (Mandrill) that sends me JSON, and have set up a Force.com public site with a RestResource to handle the incoming request. I've been noticing that if ...
Michael Welburn's user avatar
14 votes
4 answers
64k views

How to convert a number into a formatted string?

Note: there is an extensive discussion on converting a string into a decimal. This question asks how to convert a number into a formatted string. Given a decimal variable, how can I convert that ...
Ralph Callaway's user avatar
8 votes
1 answer
15k views

How can I call a method from visualforce?

You would think this would be more obvious, but "how can I call a method from a visualforce page?" Say I have something like this: <apex:page controller="PreChatController "> <script> ...
Darkenor's user avatar
  • 530
7 votes
2 answers
27k views

Remove whitespace before and after the string dynamically?

I am trying to remove whitespace (dynamically) from an input string: Input: ' inputString ' Output: 'inputString' Input: ' Ravi kumar ' Output: 'Ravi kumar' I want to remove the space before or ...
Ravindar Admin's user avatar
7 votes
5 answers
11k views

Is Apex Sometimes Case Sensitive?

I have a string set of field names populated as below: Set<String> setAllCustomSettingFields = new Set<String>(); Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe(); ...
Gabriel Rivera's user avatar
6 votes
5 answers
14k views

Get Visualforce page Name in Apex controller

I want get current page name of visulforce page. I have tried this and it works for the page having no query parameters in the URL but it fails in the pages having one or more parameters. Any ...
Krishna Bidwai's user avatar
5 votes
3 answers
4k views

Email Parsing with apex class

Anybody having knowledge regarding the Email Parsing?? I have a requirement that i receive data from email and i need to split it. for ex: *Category : (Some Data) *Type : (Some Data) I need to ...
guest610's user avatar
  • 382
4 votes
2 answers
2k views

Passing Strings by value causes memory problem

I have some functionality where I have to pass Strings between functions. The problem is these Strings can get quite big and Strings are passed by value not by reference. If you have a big String, the ...
More Than Five's user avatar
4 votes
1 answer
661 views

How can I dynamically transverse SObject fields in Apex?

I am trying to dynamically create a CSV file from Case records. The fields for the CSV file will be determined in custom settings (and therefore shouldn't be hardcoded). Moreover, the fields may ...
Brian Kessler's user avatar
3 votes
1 answer
6k views

String to ASCII

How can i convert (in APEX) a String to an Integer, which corresponds to its ASCII. What I have: String Name = 'A'; What I want: Integer Number = 65; Thanks all!
Carloss's user avatar
  • 143
2 votes
3 answers
5k views

Question About Static Methods

I'm new to Apex and development in general... So, I'm playing around coding and doing some badges in Trailhead. I created a small piece of code, as below, and have no actual use: public class ...
RedMan's user avatar
  • 107
2 votes
1 answer
4k views

JSONGenerator writeObjectField() remove backslashes

I'm trying to create an Invocable Method which allows an input of a JSON-formatted string from Process Builder as a variable. However, when I try to add the inputted JSON string using JSONGenerator....
Mike's user avatar
  • 1,199
2 votes
1 answer
14k views

Replace double quotes with single quote in a JSON string

We have JSON sent to us by webservice which has double quotes in value part (Key => Value)in the JSON String. Below is how the JSON looks like [{ "dp_id": "SDN071076", "list1": "...
sahayaraj susai's user avatar
2 votes
1 answer
5k views

Trying to parse large CSV, can't split and can't find second newline

I have a csv with about 24,000 lines that I need to parse in apex. I tried splitting the string by newline ('\n'), but got a limit error: System.LimitException: Regex too complicated I tried ...
hgolov's user avatar
  • 773
2 votes
4 answers
4k views

REGEX in Salesforce Flow to retrieve a substring

I need to retrieve a substring from a text field in a flow. is it possible by using regex instead of apex ? If i try this regex i receive false as result ( boolean ), i should get true and then i ...
Brian23Gt's user avatar
  • 131
2 votes
3 answers
302 views

Length of a delimited string with nulls ( not blanks ) in it

I was trying to do some operations on a delimited string. I chanced upon a case where I got to check the length of a delimited string with nulls in it. For Example : String str = null+', '+null ...
Lalitha A's user avatar
2 votes
1 answer
4k views

Datetime format ignores am/pm?

Hi I am new to apex coding and am trying to parse a datetime and then later on in my program I am trying to convert it back into a string to query items. For converting a string into a datetime I am ...
James's user avatar
  • 21
1 vote
1 answer
9k views

How to use Split() function inside an Expression in lightning component

I would like to use Split function inside my expression in salesforce lightning. I'm passing a map from my class and receiving the same in js controller and then converting it to List attribute for ...
AjaySFDC's user avatar
  • 618
1 vote
1 answer
7k views

Need AMPScript function to convert string to decimal

In an email I have a variable coming in that is in string format (it's a price). I need to multiply that by another number, which means I need to convert the string to a number in the xx.xx format. ...
okc's user avatar
  • 33
1 vote
1 answer
3k views

SOQL query to find a row with the longest string in a column

I was trying trying to figure out if there is a way in SOQL to select/sort rows in a table with the longest Strings in a selected column. Something similar to: SELECT Id, Name FROM User ORDER BY ...
wintermute's user avatar
0 votes
1 answer
2k views

Check For Special Characters in Emails

I'm having a business requirement of searching special characters in Email Field(before @domain.com)in a trigger. For Ex: if a email is like this (t#@[email protected]).it should be able to identify the'#...
Rishi's user avatar
  • 25
0 votes
1 answer
479 views

Trigger to Auto Assign Field value to Object Record

How do I create a trigger and trigger handler to auto assign a name for custom field on a custom object when a new record is created? The auto-assigned name should be randomly selected from a list of ...
Cassla's user avatar
  • 25
0 votes
2 answers
1k views

Query exception - Unexpected token '{'

I have below query string in an apex batch class that throw error. Can some one please help? Error Unexpected token '{' Query String String query = 'SELECT Call_Duration_Required_abv__c,Id FROM ...
Testing_SFDC's user avatar
  • 2,950
0 votes
1 answer
4k views

Escaping reserved characters from a string stored in custom setting

I want to get mykey stored in custom setting and escape the reserved characteres. originalstring = 'abc123def'pqr456\eryt' ; // escaping the reserved charatcters String ...
GroundToCloud's user avatar