3

I have a text file as follows:

/XXX/10000/XXX-15/10000 /XXX/10000/XXX-15/10000
/XXX/10000/XXX-17/10001 /XXX/10000/XXX-17/10001
/XXX/10000/XXX-18/10002 /XXX/10000/XXX-18/10002
/XXX/10000/XXX-272/10004 /XXX/10000/XXX-272/10004
/XXX/10000/XXX-322/10008 /XXX/10000/XXX-322/10008

I have task to get rid from files after the XXX-? folder so the output will be look like

 /XXX/10000/XXX-15 /XXX/10000/XXX-15
/XXX/10000/XXX-17 /XXX/10000/XXX-17
/XXX/10000/XXX-18 /XXX/10000/XXX-18
/XXX/10000/XXX-272 /XXX/10000/XXX-272
/XXX/10000/XXX-322 /XXX/10000/XXX-322

I try to find using the regex [^A-Z]/[^A-Z][0-9]*, but it returns the first digit before the /, like 5/10000, 7/10001, 8/10002 and so on, but I need to find and remove only /10000.

What am I doing wrong?

1 Answer 1

4
  • Ctrl+H
  • Find what: XXX-\d+\K/\S+
  • Replace with: LEAV EMPTY
  • CHECK Wrap around
  • CHECK Regular expression
  • Replace all

Explanation:

XXX-        # literally XXX-
\d+         # 1 or more digits
\K          # forget all we have seen until this position
/           # a slash
\S+         # 1 or more non spaces

Screenshot (before):

enter image description here

Screenshot (after):

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.