460
Views
11
Comments
Replace text for a specific position

Hi , I just trying to make calculator using string. I want to replace a specific text with another text. But when I try It replaces all text.

eg. DisplayString="2+3*9/"

      while using replace function for the last letter("/") with Values("-"). 

       output came like: DisplayString="2-3-9-"

       what I want is: "2+3*9-"

SomeOne help me to fix this :)

      


Arith_Calculator.oml
UserImage.jpg
vikas sharma
Champion

why not you using simple replace to replace the / character.

Replace(DisplayString,"/","-")



2026-02-06 06-25-47
Mohan Sigamani

because we don't know which is the last string .It may be either "+" or "-" or "/" or "*". we want to fetch last letter of string and replace with current symbols.

2019-07-01 07-16-04
Vinod Patidar

Hi Mohan,

Please use below expression -

Replace(DisplayString,Substr(DisplayString,Length(DisplayString)-1,Length(DisplayString)),"-") 
2026-02-06 06-25-47
Mohan Sigamani

Bit working but when we enter another operator for the second time it still remains same -it changes all the operators.

2019-07-01 07-16-04
Vinod Patidar

Don't understand what you you want to achieve. Could you please share OML?

2026-02-06 06-25-47
Mohan Sigamani

yeah sure. check it out :)

above in question....

2019-07-01 07-16-04
Vinod Patidar

Hi Mohan,

Could you please check attached oml.

I have changed if condition from DisplayString =  NullIdentifier() to  DisplayString = "".

Thanks

Vinod

Arith_Calculator.oml
UserImage.jpg
vikas sharma
Champion

You can use below function to replace last char of string. Here month = DisplayString

Replace(Month,Substr(Month,Length(Month)-1,Length(Month)),"*")

you can see last "/" replaced by "*"


2026-02-06 06-25-47
Mohan Sigamani

yeah but we enter for second time it changes entire  previous symbols .


UserImage.jpg
vikas sharma
Champion

could you please share sequence you output which you want after each iteration with an example. Like what is initial input, output after first iteration, output after second iteration.

2026-02-06 06-25-47
Mohan Sigamani
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.