RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Expressions by User

   Displaying page 1 of 1 pages; Items 1 to 2
Title Test Details Path from jar
Expression
jar:file:/(([A-Z]:)?/([A-Z 0-9 * ( ) + \- & $ # @ _ . ! ~ /])+)(/[A-Z 0-9 _ ( ) \[ \] - = + _ ~]+\.jar!)
Description
In java using this.getClass().getResource(""); will result in a jar:file:/ etc url ending with yourjarfile.jar!/internal/package/path/ this regular expression matches the directory before the internal jar path declaration returning the physical directory the file resides in. should work in both posix and windows machines (untested for posix*)
Matches
jar:file:/C:/installation/path/jarfile.jar!/com/regexlib/example
Non-Matches
Any text not using internal jar file url
Author Rating: The rating for this expression. Alex Ries
Title Test Details Java Get Path
Expression
(jar:)?file:/(([A-Z]:)?/([A-Z0-9\*\()\+\-\&$#@_.!~\[\]/])+)((/[A-Z0-9_()\[\]\-=\+_~]+\.jar!)|([^!])(/com/regexlib/example/))
Description
More advanced regular expression to get the full path to the directory from which your program is running. You may use this to detect the program installation dir whether you are just debugging or having a deployed program. Using the second group combined with the 7th group you'll have a full path to your program. Very useful if you use resources outside of the java package.
Matches
jar:file:/C:/installation/dir/program.jar!/com/regexlib/example/ | file:/install/dir/development/workspace/com/regexlib/example/
Non-Matches
Does not match non-java url | http:/www.regexlib.com/applet.jar!/com/regexlib/example/
Author Rating: The rating for this expression. Alex Ries
   Displaying page 1 of 1 pages; Items 1 to 2

Copyright © 2001-2018, RegexAdvice.com | ASP.NET Tutorials