I have a file path as below: \\ppk-ccr-02-llp\MOP_CIP\CO_PROJECT\alpha\stage\GOOGLE.COM_PROJECTS\bolt_cyclic_84\mango_test\8267
i want a regex to validate this in such a way that it checks
The following expression \\\\([-.\w]+\\)*[-.\w]+
should work as shown in the demo:
\\\\([-.\w]+\\)*[-.\w]+
- starting with \\
([-.\w]+\\)*
- followed by 0 or else non-empty "words" consisting of alphanumerics, .
, -
and ending with \
[-.\w]+
- entire string ending with non-empty "word" In Java code, the backslashes are additionally escaped, so the path is validated as:
String fullPath = "\\\\ppk-ccr-02-llp\\MOP_CIP\\CO_PROJECT\\alpha\\stage\\GOOGLE.COM_PROJECTS\\bolt_cyclic_84\\mango_test\\8267";
if (fullPath.matches("\\\\\\\\([-.\\w]+\\\\)*[-.\\w]+")) {
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.