What StringEx?
A free Java library supports to extract values from text based on a regex. StringEx also supports to get sub regex constructs from initialized regex.
Why StringEx?
'Cause somtimes I need it for my works and I do it for fun.
How to use?
Assume that you create a StringEx instance with regex "((\\w+)(\\(\\d{2}\\)))(\\w+)", at that time
+ matchesWithRegex("Super(99)Java") will return true, while
matchesWithRegex("Super(99Java") will return false.
+ extractAll("Super(99)Java") will return an array {"Super(99)", "Super", "(99)", "Java"}
+ extractAt("Super(99)Java", 0) will return "Super(99)"
extractAt("Super(99)Java", 1) will return "Super"
extractAt("Super(99)Java", 2) will return "(99)"
extractAt("Super(99)Java", 3) will return "Java"
extractAt("Super(99)Java", 4) will throw IndexOutOfBoundsException
+ getAllRegexConstructs() will return an array {"(\w+)(\(\d{2}\))", "\w+",
"\(\d{2}\)", "\w+"}
+ getRegexConstructAt(0) will return "(\w+)(\(\d{2}\))"
getRegexConstructAt(1) will return "\w+"
getRegexConstructAt(2) will return "\(\d{2}\)"
getRegexConstructAt(3) will return "\w+"
getRegexConstructAt(4) will throw IndexOutOfBoundsException
License: LGPL
You can see the source code here. I will upload the binary, also the source code as soon as possible.
If you want to discuss about StringEx or report error, just leave a comment here.
Update: Change license policy.
Update: Change How to use
Subscribe to:
Post Comments (Atom)
2 comments:
Sao mà "copy and paste" cái source code của bác để chạy khó quá vậy.
No hard no gain ;-)
Post a Comment