I have devised a Regex that uses the following pattern: [^.!?"]+ , in order to retrieve sentences and phrases from a given text. The pattern was tested on multiple online Regex validator sites like https://regexr.com/ and works as expected.
On Java code when I try to use the same Regex the result is not as expected.
String a =" fjefjeijfeijfei? ejfn rwfnrujnfijnf rfjnwrjrfnjrfn, rjfirjnfi4, rijijf.";
a.split("[^.?!\"]+");
The result is:
fjefjeijfeijfei? ejfn rwfnrujnfijnf rfjnwrjrfnjrfn, rjfirjnfi4, rijijf.
Instead of:
- fjefjeijfeijfei
- ejfn rwfnrujnfijnf rfjnwrjrfnjrfn, rjfirjnfi4, rijijf
What might I be doing wrong?