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
1
vote
1answer
2k views

Find a Particular Substring using Regex

I am trying my hands on Email Services, am stuck at a place where I need to create a regex. I want to find all substring which looks like "PIKA-170510-115943". Here is my code. String str='Strating ...
2
votes
1answer
2k views

System.NullPointerException when using .contains in a for loop

I am iterating through an array of a List of Maps and want to run an if function whenever an item from the list meets a condition. The problem I am currently facing is Salesforce producing the ...
0
votes
0answers
162 views

What is retString()?

I am reviewing some old code and came accross this line: List<String> segments = seg.retString(); seg has a value that's over 255 characters. When I run this method my output is empty ...
11
votes
2answers
33k views

Split string Apex

Need to split a string by first occurence of specific character like '-' in 'this-is-test-data'. so what i want is when i do split it will return 'this' in zero index and rest in first index.
4
votes
2answers
13k 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 ...
0
votes
2answers
604 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 ...
1
vote
1answer
449 views

Problem extracting values from AggregateResult, results in NULL

I admit that I haven't done too much with the AggregateResult object but I can't figure out how to successfully extract the values to add to a Set. Here's my code: public List<AggregateResult> ...
2
votes
1answer
137 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)*','') ...
3
votes
1answer
3k views

Check if a string contains a Japanese letter

I read this answer on stackoverflow that explained how a Japanese letter on a string could be detected. I tried searching for something similar to string.match() in the String Class documentation ...
0
votes
2answers
4k views

String Split method

Apex String split() results an empty list item even there is no value. For example, String test = ''; list<string> test1 = test.split(','); System.debug(test1.size());    // Result = 1 so I ...
0
votes
1answer
214 views

How to use capitalize() method in inputField in visualforcepage?

I am trying to make first letter caps using inputField in Visualforce page. I tried with below code: created string and assigned to Inputfield. <apex:inputField value="{!...
0
votes
2answers
2k views

Syntax for passing Multidimensional array

I have a method in my controller util file that parses through some strings to find matches I need to pass in a multidimensional array. When I call this method in various controllers how in Apex do ...
1
vote
3answers
1k views

Logically comma separating address field to form a String

I am trying to create a string of address in this format: Street, City, State, Country, Zip. Assume that there is an Address object called addr which has account's shipping address. Address addr = ...
8
votes
1answer
5k views

Replace Line Breaks (Multiple count as 1) in a string

Given a string with the following variations where {br} is a line break not a literal Line 1{br}Line 2 Line 1{br}{br}Line2 Line 1{br}{br}{br}Line 2{br} Basically any number of line breaks between ...
3
votes
2answers
22k views

How to check empty value in a string?

I have array with list of class. public class filterField { public String label {get;set;} public String searchFieldName {get;set;} public String searchValue {get;set;} public ...
2
votes
1answer
478 views

How do I convert a Blob into an alphanumeric string and back?

There's a Blob I generated by encrypting a certain string: Blob data = Blob.valueOf('my string'); Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data); Is there a way to ...
1
vote
1answer
6k views

UPPER case in lightning component

I build a lightning component for my org. One of my attribute is a String value inside a collection of a custom object. Somentimes this String is in lowercase and sometimes is in uppercase. I want to ...
0
votes
1answer
61 views

Efficiently transforming values inside a delimited string

I have a String extDB_Table__c.inputString__c that looks like this: MTHS|||ECON|||SPN||| The ||| is meant to be a delimiter between whatever values are in the string (comes after every value, ...
0
votes
0answers
45 views

breakline in string to pdf

I have an apex:component controller from where I pass a string to `</messaging:attachment <c:TrainersListComponent TrainingIdAttr="{!relatedTo.Training__c}" /> Which is rendered as PDF: &...
8
votes
3answers
15k views

How to check if String is Decimal?

Seems like String.IsNumeric() returns TRUE if it's integer. String numString = '12'; System.Debug(numString.IsNumeric()); If it's a decimal (eg. 12.2) this is returning FALSE. I believe it should ...
0
votes
0answers
565 views

Regex too complicated when splitting a string [duplicate]

I am trying to get the Standard Report As a csv file and try to split the file and need to do some conditions. But for the large amount of records am getting error as: Regex too complicated ...
2
votes
1answer
1k views

Apex String Split with single quotes

I have a String array as follows String [] toAddress = new String [] {'abc@example.com','def@example.com','xyz@example.com'}; I would like to get the output as 'abc@example.com','def@example.com','...
2
votes
2answers
2k views

Query sObject type with dynamic name

Can I create a list variable dynamically in Saleforce? Like this: String objectName = 'Noise_Dictionary__C'; List<ObjectName> lstObject = new List<ObjectName>([select id from ObjectName ...
1
vote
1answer
216 views

parser to convert values including fraction to decimal

I have one Fields planValue_c set as %age in salesforce. Possible inputs when reading from file are like 20 -Integer 20 2/3- Integer with fraction ( space is delimiter) 2/3 - Fraction Assuming ...
0
votes
1answer
92 views

Not able to display Multiple string in visualforce page from controller

I have a Multiple Product and each has it's own UnitPrice i am just passing it to String variable and store it inside the for loop but not sure How to display each of them in visualforce page here ...
0
votes
2answers
545 views

String Split - Calculate length of individual splitted parts

For a string like : String strTest = '123456.78'; system.debug(StrTest.split('\\.')); The result is USER_DEBUG [2]|DEBUG|(123456, 78) How can I get the individual length of the splitted parts ?...
0
votes
2answers
157 views

Return characters in a string from field's data

I have to return specific characters from a field's data. The scenario is I have a Text field which has some data (a1h5D0000055ZLfETC-547561-12) and I need to find and return last 2 characters from ...
1
vote
1answer
2k views

How to convert List<String> in Specific String Format?

List<String> listoflang=new List<String>(); listoflang.add('Apex'); listoflang.add('PHP'); listoflang.add('Java'); and I want this list to be converted in string like this Apex;PHP;Java
3
votes
1answer
192 views

Newbie - First Apex Class question re: No viable alternative character

I'm doing one of the Trails, converting my .NET and Java knowledge over. I'm stumped on a really simple task. Objective: Return a list of accounts where the BillingState is the same as the state ...
16
votes
3answers
4k 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 ...
0
votes
2answers
117 views

How to Convert String date and time to Regular date and time in apex

I wanna convert String date and time to Apex date and time. 2016-12-23T07:26:33+0000 => DateTime Of apex. How to convert ?
5
votes
2answers
3k views

Unicode non-breaking space is not considered white space?

Can anyone confirm that Unicode \u00A0 non-breaking space is not considered "whitespace" by Apex and is not detected by trim(), deleteWhitespace, or regex? I'm surprised by regex since I though \s ...
1
vote
2answers
139 views

How to replace {!Custom_Object.Account.Name} in a string to real value? [closed]

We have a scenario to replace {!Custom_Object.Account.Name} to account name like that we have multiple value in that string. String subject = 'Hello this account belongs to {!Custom_Object.Account....
0
votes
1answer
72 views

How do I get default Developer Console output date format?

I'm trying to get the DateTime field values formatted to example below which is the Developer Console Query editor output. e.g. 2017-01-04T06:00:00.000+0000 But when I used String.valueOf(...
1
vote
4answers
2k views

Integer to ASCII conversion

I'm trying to convert an integer into its corresponding ascii value but getting different result than what I get in java. Java int c = 5032; char c1 = (char)c; System.out.print('==>' + c1); //...
1
vote
3answers
177 views

generateRandomString

I have trigger which generates random String whenever a record is created. whenever i try to create a record (On clicking the save button), the following error is popping System.LimitException: Apex ...
0
votes
1answer
899 views

Parse HTTP Response

How to parse the HTTP Response if response string is in name value pair. RESULT=0&PNREF=EFHP0D426A53&RESPMSG=APPROVED&AUTHCODE=25TEST&AVSADDR=Y&AVSZIP=N&CVV2MATCH=Y
1
vote
3answers
3k views

Check If String Starts With Any Of A Set<String>?

This is basically what I'm trying to accomplish: I have a Set of strings, for example: Set<String> emails = new Set<String>{'abuse@','database@','fbl@','ftp@'}; I also have a list of ...
0
votes
1answer
51 views

is there optimized way to check a string is a numeric and decimal?

I have operator and value as string. When my operator equal to '>' or '<' then i need to ensure the value of the string is numeric or Decimal so it can wrk for both. But i see only isNumeric() ? ...
1
vote
1answer
4k views

Convert String array to Set of string in apex class

Can someone please help me to convert String array values to Set of string? I have below code where it says Set is not getting populated from string array. Criteria=[SELECT Franchise__c FROM ...
2
votes
3answers
9k views

Dynamic SOQL query

I'm trying to build a dynamic query but I think I may have the wrong syntax. String query = 'SELECT ProjectId__c from Project__c' projectList = Database.query(query + ' WHERE Name__c equals 'pp2'); ...
0
votes
3answers
2k views

break line on a String

This is my query: String query = 'SELECT Project__c, Project__r.Testing_Submitted__c, Project__r.Project_Sub_Phase__c, Project__r.DRD_Submited__c,Protected_Application__r.DRD_Completed__c, ...
2
votes
2answers
4k views

Decimal formatted number in APEX

I want to format a Decimal field as a 6 digit String. The field is a Decimal(6,0) and I want it to be a string of 6 characters with any necessary leading zeroes. 1 => 000001 2 => 000002 12 =&...
0
votes
1answer
313 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?
3
votes
1answer
2k views

String.valueOf strange behaviour

I am iterating a list of task and converting its fields in string, all fields are converted into string except activitydate. It is showing strange behaviour, out of 10 tasks only 3 tasks are coming in ...
2
votes
1answer
2k views

Making a string in apex class bold? [closed]

Is there a way to make a string in apex class bold? I am generating a CSV file as email attachment in a apex class and sending it. Now the header of the CSV file is in a string format: string header ...
3
votes
3answers
3k views

How to remove text field value after comma using apex code?

I have text field and that field has these two email address, field value is look like abc@test.com, def@test.com Now, i need to remove second email address after comma.. i wrote some code to ...
3
votes
1answer
930 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 += ...
0
votes
1answer
8k views

How to Remove Single Quotes from String?

I have a String like Status = 'Submit', and I want to remove the single quote characters ('). So my desired output is Status=Submit.
1
vote
1answer
1k views

Natural sorting(Text with Numbers) for String in Apex [closed]

I must sort strings like "Text x.x.x(Text x)", "Text x.x.x", etc.(where x - number) in right way in Apex. Something like that: Input - ['Test 1.2(V 1000)', 'Test 1.10(V 1001)', 'Test 1.2(V 1001)', '...

1
3 4
5
6 7
9