I'm working on a utility to assist others in resolving dependency hell. I can extract the UNIX path output by ldd but in one case my regex is not able to handle the presence of 2 +'s in the filename. My regular expression is below:

((?:\\/[\\w\\.\\-]+)+)

Any ideas how I could modify this to handle the +'s?

Test data is:

libstdc++.so.6 => /usr/lib32/libstdc++.so.6 (0xf5431000)

Thanks in advance if anyone has input.

有帮助吗?

解决方案

Inside the square brackets, the . and - lose their special meaning (well - the - loses it when it's the last one. Why not just add the+` to the allowable characters:

((?:\/[\w.+-]+)+)

See demo: http://regex101.com/r/vN4bJ2

enter image description here

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top