I need to find the regular expression to use as an argument in string.matches
.
I have a text of strings separated by space " "
and i want to find what type of Number is it. First of all i need to check pattern like this: "[number] E [number] & [number]"
. &
is a symbol in the string, so is E
.
// so *word* is a string tested
if (word.matches("\d++ E *\d++ & \d++")) *something like that*
For example "1001Ε101&2"
is true and "0114&2"
is false.
So I need the regular expression in word.matches(" *answer* ");
It's a project in lexical analysis. I must not use ready lexers.
Your regex is almost right. Simply use it this way:
with
word
the string to check.Don't forget to use a double
\
in your regex string where you would put a simple\
.