public with sharing class ReplaceStr
{
public Stringrepla(String str,Integer size)
{
String tempStr = '';
Integer startSize =0;
Integer endSize = size;
for(Integer i = 0;i <= str.length()/size ;i++)
{
if(endSize>=str.length())
{
endSize=str.length();
}
tempStr=tempStr+'\n'+str.substring(startSize,endSize);
startSize = startSize+size;
endSize = endSize+size;
}
return tempStr;
}
}
//此处为你需要处理的字段。
ReplaceStr rep = new ReplaceStr();
receiptNotice.Account__r.Address__c=rep.Stringrepla(receiptNotice.Account__r.Address__c,30);
另一种形式: \R\N