0

Is there a function to test if a string contains valid code in Java? I have a bunch of strings (e.g. 2.0+0.0+pow(2.0),2.0, obviously this one doesn't work) that I need to verify this for. I can add things to the beginning and end, so it doesn't much matter what language I'm testing:

python:

x = 2.0+0.0+pow(2.0),2.0

Java:

float x = 2.0+0.0+pow(2.0),2.0;

JavaScript:

var x = 2.0+0.0+pow(2.0),2.0;

as long as I can test it in Java.

I found this: How to tell if a string contains valid Python code, but that's for testing in python, not Java.

Thanks in advance!

0 Answers0