Thursday, 8 August 2013

Java Regex only start of string

Java Regex only start of string

I have a huge string which I would like to match to the following regex:
"\\s*<?.*?>\\s*<abc>[\\s\\S]*|\\s*<abc>[\\s\\S]*"
as in
myHugeString.matches("\\s*<?.*?>\\s*<abc>[\\s\\S]*|\\s*<abc>[\\s\\S]*"));
The string is enormous, so matching the [\s\S]* at the end is taking up a
huge amount of time. I am looking to only match the first portion
(\\s*<?.*?>\\s*<abc>), and I don't care about anything after that.
What would be the most efficient way of going about this
Thanks

No comments:

Post a Comment