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
4
votes
1answer
767 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 ...
5
votes
2answers
3k 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 ...
4
votes
1answer
696 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}\...
7
votes
1answer
3k 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 ...
4
votes
3answers
4k 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 ...
8
votes
3answers
39k 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 file: config-qa1.txt\"","...
1
vote
1answer
1k 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 ...
0
votes
1answer
426 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 ...
12
votes
1answer
20k 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 ...
28
votes
4answers
59k 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 == ...
5
votes
5answers
8k 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 ...
4
votes
2answers
1k 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 ...
8
votes
3answers
22k 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 ...
8
votes
1answer
14k 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> ...
5
votes
3answers
2k 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 ...
4
votes
1answer
3k views

Email Template Replace merge field

I have an email template which uses merge fields from a custom object. For reasons difficult to explain here, I have to write my own code to read the body of the email template in Apex, replace merge ...
2
votes
1answer
1k 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....
0
votes
2answers
329 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 ...
4
votes
1answer
551 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 ...
3
votes
2answers
7k 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 ...
3
votes
1answer
671 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 +=...
2
votes
1answer
3k 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 ...
2
votes
3answers
231 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 ...
1
vote
1answer
4k 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 ...
1
vote
1answer
518 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 ...
0
votes
1answer
489 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#@est@gmail.com).it should be able to identify the'#...
0
votes
1answer
273 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 ...