427
Views
15
Comments
Solved
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

2020-08-31 05-04-40
Rahul Jain
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
2021-01-05 18-22-18
andrew mahfouz

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


How can I do this

2020-08-31 05-04-40
Rahul Jain
It will be work as per your requirement

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

 

2020-08-31 05-04-40
Rahul Jain
Reverse5Letter.oml
2021-11-18 18-03-41
AJ.
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
2021-01-05 18-22-18
andrew mahfouz

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

How can I do this

2021-11-18 18-03-41
AJ.

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
2021-05-18 02-27-17
Manish Gupta
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. 

2021-01-05 18-22-18
andrew mahfouz

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


How can I do this

2021-01-05 18-22-18
andrew mahfouz

i need if i enterd : andre mhafouz

the output will be  : mhafouz erdna

how can i do that 

2024-07-05 14-16-55
Daniël Kuhlmann
 
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
2021-01-05 18-22-18
andrew mahfouz

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


How can I do this

2024-07-05 14-16-55
Daniël Kuhlmann
 
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.

2021-01-19 14-07-32
Tom Zhao

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 

2021-11-18 18-03-41
AJ.
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
2021-01-05 18-22-18
andrew mahfouz

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

How can I do this

2021-11-18 18-03-41
AJ.

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
2021-05-18 02-27-17
Manish Gupta
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. 

2021-01-05 18-22-18
andrew mahfouz

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


How can I do this

2021-01-05 18-22-18
andrew mahfouz

i need if i enterd : andre mhafouz

the output will be  : mhafouz erdna

how can i do that 

2020-08-31 05-04-40
Rahul Jain
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
2021-01-05 18-22-18
andrew mahfouz

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


How can I do this

2020-08-31 05-04-40
Rahul Jain
It will be work as per your requirement

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

 

2020-08-31 05-04-40
Rahul Jain
Reverse5Letter.oml
2024-07-05 14-16-55
Daniël Kuhlmann
 
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
2021-01-05 18-22-18
andrew mahfouz

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


How can I do this

2024-07-05 14-16-55
Daniël Kuhlmann
 
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.