maybe my question doesn't match with the content of the message but I hope I explained my problem good.
I have two scenarios
First scenario:
If I recive Strings like this:
x = x + 10;x = x + a [i]; x = x + a [i] +10;
note: the letters can be different here and the examples can differ too. I separated the side before the = sign from the side after the = sign So I've got ArrayList where the elements look like this:
- Index 0 -> x
- Index 1 -> x + 10
- Index 2 -> x
- Index 3 -> a [i]
- Index 4 -> x
- Index 5 -> x + a [i] +10
I want to make a comparison now between the sentences, so I will make a comparison between Index 0 and Index 1 and between Index 2, Index 3, and so on.
Let's name the side before equals (the left side) to str1 and after the equal (the right side) to str2
Is there a possibility to make a comparison between the two sides and said if the str1 is variable and str2 two is the name of the same variable and array come after the name of the variable like the following example:
x = x + a[i] * 10;
we return false. But if the name of the variables is different from each other we return true like the following example:
x = y + a[i] + 10;
so false will be return on something similar to this:
x = x + a[i];
or
x = x + a[i] + 10;
note: the letters could be different. I mean we could have something like this:
sum = sum + a[i]; and so on.
The second scenario:
Note: Letters and numbers can be changed.
if I have string like the following:
a [i] = b [i] + c [i];
or
a [i] = b [i + 1] * c [i] +10;
I was able to separate the side before = and the side after = in the same way as I mentioned before, and it looks like this:
- Index 0 -> a [i]
- Index 1 -> b [i] + c [i]
- Index 2 -> a [i]
- Index 3 -> b [i + 1] * c [i] +10
the question here is:
Can I separate the left side from each other as well? I mean, I want the first sentence to be such
- a [i] by itself
- b [i] by itself
- c [i] by itself
same things about the second example because I want to compare like this: a [i] with b [i]
and compare a [i] with c [i]
What I have tried:
I split the string using ";" then I separate between the two sides as I mentioned above and I used charAT but I don't know how to find out about the rest of the statement like in this example: x = x + a[i]; it will return 1 because x = x but I don't know how to check for the rest of the string, and How I separate the string more like this example: a[i] = b[i] + c[i+1];
Thank you in advance