+ 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