Jump to content

Help Reverse String


azro Maktoum
 Share

You are about to reply to a thread that has been inactive for 4269 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Ahh - ok - I interpreted that as a typo. It would be helful if you stated such non-obvious matters.

I think, what you want isn't really possible in the strictest sense. Apart from the fact, that you would have to define "English String" (what if expressions like a vector shows up - it's not an English word - but it's no number either. 

 

You could, hoever , to get as close as possible, look at something like this function (or the parts of it you need) to find out wehere you'd have to stop the reversal, generate the non-reversed sub-string, then insert this non-reversed sub-string into the new string an move on happily to reverse the string

  • Like 1
Link to comment
Share on other sites

Something along these lines should work:

 

integer IsInteger(string var) {	// This is from the wiki    integer j;    for (j=0;j<llStringLength(var);++j) {        if(!~llListFindList(["1","2","3","4","5","6","7","8","9","0"],[llGetSubString(var,j,j)])) return FALSE;    }    return TRUE;}string ReverseString(string var) {	string retval = "";	integer i;	for(i=llStringLength(var); i > 0; i--) {		retval += llGetSubString(var,i,i);	}	return retval;}string ReverseWords(string in){	list outlist = [];	list words = llParseString2List(in, [" "], []);	integer i;	for(i=0; i<llGetListLength(words); i++)	{		if(IsInteger(llList2String(words,i)==FALSE)		{			outlist += [ ReverseString(llList2String(words,i)) ]; 		}		else		{			outlist += [ llList2String(words,i)) ];		}	}	return llDumpList2String(outlist," ");}

 

Then, wherever you want to reverse the non-number words in the string, simply call ReverseWords(whatever) and it should do it.

 

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4269 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...