function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DivyaReddyDivyaReddy 

Regarding Displaying String after Hyphon

Hi to all ,

 

I have one string that has been divided and i have to display the string after  Hyphon.

Can any one help om this issue . 

RollynRollyn

String methods found in:

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_string.htm

 

You can use split and get the position value

 

String str = 'STR1-STR2;

str.split('-')[1];

 

DivyaReddyDivyaReddy

Thank q for u reply

 

 

But i want to sort it in vf page , can we do this 

LakshmanLakshman

Yes you can do this using javascript. Here is a code snippet to it:

 

<apex:page>
<script type="text/javascript">
function mySortedArray(arr1)
{
var arr = arr1.split('-');
alert('Sorted Array is:'+arr.sort());
}
</script>
<input type="button" class="btn" value="Sort" onclick="mySortedArray('b-c-a-d');"/>
</apex:page>

 Let me know if you are facing any issues in this.

 

Regards,

Lakshman