S
S
Shellr57s2019-07-03 03:41:45
Regular Expressions
Shellr57s, 2019-07-03 03:41:45

How can I delete everything except what was found?

There is text and many lines
In the text there are $s1 $s2 $s3 $s4 $c1 $c2 $c4
Each line has at least 1 such text, there can be 2 and 3 in 1 line, but without duplicates.
I was able to find them like this (\$s\d)|(\$c\d) and I can delete them all, but I did not understand how to delete everything except them.
Thanks in advance for your reply!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dodo512, 2019-07-03
@Shellr57s

https://regex101.com/r/o1MljH/1/
Find: .*?($|\$[sc]\d)
Replace:$1

A
Alexey, 2019-07-03
@Azperin

Well, just put a negative[^$\d | ^$c\d]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question