Java RegEx meta character (.) and ordinary dot?

Viewed 265854

In Java RegEx, how to find out the difference between .(dot) the meta character and the normal dot as we using in any sentence. How to handle this kind of situation for other meta characters too like (*,+,\d,...)

9 Answers

If you want to end check whether your sentence ends with "." then you have to add [\.\]$ to the end of your pattern.

I am doing some basic array in JGrasp and found that with an accessor method for a char[][] array to use ('.') to place a single dot.

I was trying to split using .folder. For this use case, the solution to use \\.folder and [.]folder didn't work.

The following code worked for me

String[] pathSplited = Pattern.compile("([.])(folder)").split(completeFilePath);
Related