Compare Two String or Variables

studio
variable

#1

Hi Guyz,

I need help on following thing, see am taking two outputs from webpage using get attribute “aaname” and storing the values in variables. Now I need to check if two variables are same I need write into excel one value or two variables or not matching then I write into excel some other value.

For Ex: AA001 = AA001 THEN my output on excel is AA001
AA001 = THIS IS INCORRECT THEN my output on excel is error (or) blank

it’s possible to achieve in if statement or any other. Please guide me. Thank you.

Gokul.


#2

Hello Gokul,

I’ve made two variables as String as below.

String firstString = “AA001”;
String secondString = “AA001”; // with same value
// am comparing them using if condition
if(firstString.equals(secondString)){
// then write AA001 into excel or
}else{
// don’t write anytime
}

please let me know. once it’s success.

Thanks,
Pankaj


#3

Hi @gokulvasant,

yes you can achieve using if condition itself.

you can try this code

Regards,
Arivu


#4

@arivu96 and @Pankaj.Patil

Thanks a lottttttt…

It’s working :slight_smile:


#5

Hi… one more thing guyz,

how can we remove “/” in a string for ex: string = “20/12/1955” I need “20121955”.

Please help me out thanks a lot once again.


#6

Hi @gokulvasant,

strValue=strValue.Replace("/","")

Regards,
Arivu


#7

Hi…

Thanks a lot.


#8

Good to hear :slight_smile: