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
7
votes
2answers
17k views

Coverting a String to Array of Characters

I would like to ask a simple question but seems to be complex if we talk in context of Apex programming. Like in java we have a simple method to get the array of characters by using public char[] ...
2
votes
2answers
225 views

Unable to save URL's as a list of string values

I'm not certain if once I've created a URL via a string, it needs to be treated as a WebLink in order to save it in a list, but every time I try to save a list of them as strings, I get an empty list. ...
2
votes
1answer
4k views

Problem using string replace method

I'm attempting to replace a portion of a large text area using the code below without success. Have I misunderstood the proper usage of the string replace method, and if so, is there another ...
3
votes
0answers
136 views

Email 2 case comment - how to remove the original email

I'm creating a case comment from an inbound email. The created comment already contains the original email (see below). test reply 2 On Wed, Jun 19, 2013 at 10:12 AM, Support wrote: Dear itay, ...
4
votes
1answer
2k views

Curious string comparison issue when string starts with a dash

Try the following example in an anonymous Apex window: String s = '- Default - '; system.debug(s.CompareTo('Banner')<0); // True system.debug(s<'Banner'); // False s = '/ Default -'; system....
4
votes
2answers
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 ...
7
votes
3answers
5k views

Unable to use multiline with pattern

I'm trying to match a string with Pattern/Matcher, however it is failing because I cannot set Pattern.MULTILINE like the Java documentation uses. String testString = 'Line 1: Does not match\nCustomer ...
-3
votes
1answer
3k views

Pulling picklist options from a multi-value field

I am currently pulling select options for a multi-value picklist from a query which gathers field values from all of the child records from a certain __r relationship of an account. I would like to ...
-2
votes
1answer
32k views

How to assign string to date type in apex code [closed]

In my code i am getting this error: Illegal assignment from String to Date Kindly anyone explain how to assign a string to date field in List (APEX code). Here is my code: for (Integer i=1; i<...
2
votes
1answer
3k views

Replace text in Rich text area field with trigger

We're using the "Solutions" standard object as our knowledge base, with "Solution details" standard field is a Rich Text Area field (32000 characters). The field structure looks like this: Purpose (...
3
votes
2answers
2k views

Extracting number values in a text field then summing up

I have this field that gets populated by an external service and I want to extract the number values from it then sum the numbers up. For instance, see the text below United Kingdom: 3, Ireland: 1, ...
30
votes
1answer
17k views

Bug in String.split('.')?

I can hardly believe it but split() doesn't work on the . character: String createDate = '01.2.2013'; String[] cd = createDate.split('.'); System.assertEquals(3, cd.size()); // Boom! Tried with '\....
5
votes
1answer
2k views

I need a String method in a Trigger to validate if a Rich Text Area is blank

I need assistance in evaluating whether a Rich Text Area custom field is blank using an Apex trigger. Rich Text Field name: Application_Workaround__c I have tried the following within the context ...
3
votes
1answer
3k views

Using RegEx Pattern Match to create DateTime fields in trigger

How do I write code with the correct syntax to run a pattern grouping match within a string, then replace the pattern groups found in the result so that they follow a desired pattern? I've never done ...
7
votes
2answers
625 views

Case sensitive highlighting of keywords

we have a rich text field in one of our objects that contains an html-document. I have created a search page and a user can click on a 'preview'-button which opens the html in a lightbox. I want to ...
2
votes
3answers
8k views

Comparing IDs - use String or don't use Strings

I have some logic where I need to iterate thru a bunch of Opportunities. I need to be able to determine when I hit a new Opportunity Owner ID. I try: String lastownerId = ''; for (Opportunity ...
11
votes
3answers
8k views

How do I do a case-insensitive replace all for a string?

I've got a project where I'd like to replicate some of the internal merge field functionality so users can build a link and it'd be really helpful if I could do a case-insensitive string replaceAll. ...
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> ...
2
votes
3answers
4k views

Encode Long Text Area field

I am working on some code that retrieves certain cases and then emails those cases as a csv. This is working to some extent. The problem I have is that one of the fields is 'Description' which is a ...
2
votes
1answer
2k views

New string methods substring Before/After, etc

I'm playing with the new string toys. I'm getting something out of a CSV (and I have very good reason to need to do that). I tried this: contents = contents.substringAfter('/n') and it's not finding ...

1
5 6 7 8
9