how can i reverse text
Application Type
Reactive

how can i reverse text (client side)

if i have input text : wsda

 i need the output : adsw

Is there any idea

mvp_badge
MVP
Solution

Here is another JavaScript solution that does not require 2 reverse, a split and a join, and should perform faster.

It has one client action wrapping the following JavaScript recursive function:

function reverseString(str) {
  return (str === '') ? '' : reverseString(str.substr(1)) + str.charAt(0);
}
ReserveStringViaJavaScript.oap

If I want to reverse the first five letters only, and the rest is displayed as it is entered


How can I do this

mvp_badge
MVP

Andrew, this is not the first time you ask something, the the community comes and help you, then you change your question. Please value our (volentary) time to help you and ask the question right the first time.

Solution

Hi  Andrew ,

I hope it will be helpful for you .You can use  below javascript. 

var string = "erehT era a tsav rebmun fo secruoser rof gninrael erom tpircsavaJ";
// you can split, reverse, join " " first and then "" too
string.split("").reverse().join("").split(" ").reverse().join(" ")

Please check by below url and attached OML File. 

https://rahuljain877.outsystemscloud.com/home/Screen1


Reverse.oml

If I want to reverse the first five letters only, and the rest is displayed as it is entered


How can I do this

It will be work as per your requirement

https://rahuljain877.outsystemscloud.com/home/Screen1

 

Reverse5Letter.oml

Champion
Solution

Hello Andrew

With the client side do you mean with JavaScript? 

Please look into this demo if it works for you - https://personal-9qwkrkgl.outsystemscloud.com/ForumHelp/ReverseString?_ts=637594334984186669


Type any string and click on Reverse. 

If I want to reverse the first five letters only, and the rest is displayed as it is entered


How can I do this

i need if i enterd : andre mhafouz

the output will be  : mhafouz erdna

how can i do that 

Solution

Hello @andrew mahfouz,

The forge component suggested above is a great fit especially as it has several other features you can use.

If for any reason you are not inclined to use a forge component for this particular need then you can do it yourself in as few steps as shown below. If interested, feel free to review the attached oml.

Regards,

AJ

StringReverse.oml

If I want to reverse the first five letters only, and the rest is displayed as it is entered

How can I do this

Hi @andrew mahfouz,

In your new request, you want only the first 5 letters (characters I presume?) to be reversed, but looking at the example you provided Manish Gupta (screenshot below) you actually need the first 6 characters to be reversed, to get the output you desire.

The attached updated OML gives you the flexibility to decide how many characters from the start of the string, should be reversed. Result of the attached oml shown below:

Cheers,

AJ

StringReversev2.oml

Champion

Hi andrew

The easy way will be to use a forge such as below.

https://www.outsystems.com/forge/component-overview/5107/string-utils

If you are familiar with C#, then you can make your own extension.

var rev = new string(s.Reverse().ToArray());

Kind regards 

Solution

Hello @andrew mahfouz,

The forge component suggested above is a great fit especially as it has several other features you can use.

If for any reason you are not inclined to use a forge component for this particular need then you can do it yourself in as few steps as shown below. If interested, feel free to review the attached oml.

Regards,

AJ

StringReverse.oml

If I want to reverse the first five letters only, and the rest is displayed as it is entered

How can I do this

Hi @andrew mahfouz,

In your new request, you want only the first 5 letters (characters I presume?) to be reversed, but looking at the example you provided Manish Gupta (screenshot below) you actually need the first 6 characters to be reversed, to get the output you desire.

The attached updated OML gives you the flexibility to decide how many characters from the start of the string, should be reversed. Result of the attached oml shown below:

Cheers,

AJ

StringReversev2.oml

Champion
Solution

Hello Andrew

With the client side do you mean with JavaScript? 

Please look into this demo if it works for you - https://personal-9qwkrkgl.outsystemscloud.com/ForumHelp/ReverseString?_ts=637594334984186669


Type any string and click on Reverse. 

If I want to reverse the first five letters only, and the rest is displayed as it is entered


How can I do this

i need if i enterd : andre mhafouz

the output will be  : mhafouz erdna

how can i do that 

Solution

Hi  Andrew ,

I hope it will be helpful for you .You can use  below javascript. 

var string = "erehT era a tsav rebmun fo secruoser rof gninrael erom tpircsavaJ";
// you can split, reverse, join " " first and then "" too
string.split("").reverse().join("").split(" ").reverse().join(" ")

Please check by below url and attached OML File. 

https://rahuljain877.outsystemscloud.com/home/Screen1


Reverse.oml

If I want to reverse the first five letters only, and the rest is displayed as it is entered


How can I do this

It will be work as per your requirement

https://rahuljain877.outsystemscloud.com/home/Screen1

 

Reverse5Letter.oml

mvp_badge
MVP
Solution

Here is another JavaScript solution that does not require 2 reverse, a split and a join, and should perform faster.

It has one client action wrapping the following JavaScript recursive function:

function reverseString(str) {
  return (str === '') ? '' : reverseString(str.substr(1)) + str.charAt(0);
}
ReserveStringViaJavaScript.oap

If I want to reverse the first five letters only, and the rest is displayed as it is entered


How can I do this

mvp_badge
MVP

Andrew, this is not the first time you ask something, the the community comes and help you, then you change your question. Please value our (volentary) time to help you and ask the question right the first time.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.