Need to remove first -symbol

I need to remove first - symbol
Example:(-(-100+123)+(78+9)-(45+67))

Output should be
Example:((-100+123)+(78+9)-(45+67))

Hi @sruthesanju

Try this
System.Text.RegularExpressions.Regex.Replace(ā€œ(-(-100+123)+(78+9)-(45+67))ā€,ā€œ(?<=^()\Sā€,ā€œā€).ToString

Regards
Sudharsan

need to remove first - symbol
Example:-(-100+123)+(78+9)-(45+67)
Output should be

Example:(-100+123)+(78+9)-(45+67)

Use this
System.Text.RegularExpressions.Regex.Replace(ā€œ-(-100+123)+(78+9)-(45+67)ā€,ā€œ^-ā€,ā€œā€).ToString

Regards
Sudharsan

1 Like

Hello @sruthesanju
below should work fine for you
Log message = "-(-100+123)+(78+9)-(45+67)".Trim("-"c)

but remember it is going to trim all of the - at start or end like below

log message = "----(-100+123)+(78+9)-(45+67)-----".Trim("-"c) will out put this ā€œ(-100+123)+(78+9)-(45+67)ā€

Update: Corrected syntax for trim from Trim(ā€œ-ā€) to .Trim("-"c)

It will check the above screen shot

Hi @sruthesanju,

yourValue = "(-(-100+123)+(78+9)-(45+67))"

yourValue = "(" + yourValue.Substring(2)

Regards,
MY

1 Like