I want to remove all directorynames from a path:
Payload/brownie.app/Info.plist
should become
Info.plist
What regex should I use or can I use replace() from String in java? thanks!
On the other hand, the \S+ (uppercase S ) matches anything that is NOT matched by \s , i.e., non-whitespace. In regex, the uppercase metacharacter denotes the inverse of the lowercase counterpart, for example, \w for word character and \W for non-word character; \d for digit and \D or non-digit.
By placing - at the start or the end of the class, it matches the literal "-" . As mentioned in the comments by Keoki Zee, you can also escape the - inside the class, but most people simply add it at the end. You can also escape the hyphen with a backslash, [a\-z] .
Use os. path. dirname() to get the directory folder (name) from a path string.
In order to obtain the Current Working Directory in Python, use the os. getcwd() method. This function of the Python OS module returns the string containing the absolute path to the current working directory.
Try with this:
new File("Payload/brownie.app/Info.plist").getName()
This returns the filename without directories.
Example:
String filename = new File("Payload/brownie.app/Info.plist").getName();
System.out.println(filename);
Outupt:
Info.plist
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With