Reputation: 355
I want to write a regex which matches strings based on the following:
/
*
, :
) before or after /
/
and as longs as there is no space it should be considered as a single matchSample input looks like
Artifacts path 'artifacts_tube/AtomInstall*/**' not found. // 1 match
</root> // 0 matches
Failed steps: [<DF2 [D:/Users/work/tmp/assets/dummyfailer]>] // 1 match
Options : *.* /NS /NC /NDL /COPY:DAT /NP /MT:32 /R:11 /W:30 // 0 matches
Copy Dir: D:/Users/tempdir/tmp8fo -> D:/Users/tempdir/tmpj7xj // 2 matches
I have a simple regex but it does not meet all of the above criteria
\S*\/\S*
. Output for my regex
Artifacts path 'artifacts_tube/AtomInstall*/**' not found. // 1 match
</root> // 1 match
Failed steps: [<DF2 [D:/Users/work/tmp/assets/dummyfailer]>] // 1 match
Options : *.* /NS /NC /NDL /COPY:DAT /NP /MT:32 /R:11 /W:30 // 8 matches
Copy Dir: D:/Users/tempdir/tmp8fo -> D:/Users/tempdir/tmpj7xj // 2 matches
Upvotes: 1
Views: 684
Reputation: 6056
This is not exactly what you asked for (it allows :
and *
to occur anywhere in the path) but I think you can achieve your goal with it.
(?!\/[^:*])(?![^:*]\/)[\w\/*:]*\/[\w\/*:]*
Upvotes: 1
Reputation: 140
This regex should work for what you need
[*:](?!\s)\/[\s]*[:*]*
https://regex101.com/r/nI18g9/1
Upvotes: 1