I want to do right to left backwards search as in .net.
My regex is ^(.*\\S+.*$) .
How can i implement it in Java?In .net We have RegexOptions.RighttoLeft and Java regex engine doesnt allow backward searching.
So i am looking for alternatives.
Just as Prem Pillai said, reverse the string and then match.
SCJP 6, OCMJD 6, OCPJWSD 6
I no good English.
Lucky J Verma
posted 8 years ago
I did the same ,reversed the string and reversed it back after output.
To Pillai's Qn- I need to do Backward search because i look for a search word in a document and then pick previous 2 lines and next 2 lines and current line.
So for previous lines, i do backward matching.
How much good it is in performance wise to do this.-
reverse the string ,
reverse the pattern (I dint need this ,because i search line by line)
Mapping the index
then reverse back and also i am using collection to pick up all the lines ,reverse collection too.