F
F
Free0wl2020-07-14 10:34:38
linux
Free0wl, 2020-07-14 10:34:38

RegEx - remove text from listing...?

have text:
+7 999 888-77-66 Last name first name
here text from Last name first name
here text from Last name first name
here text from Last name first name
+7 999 888-66-55 first name55 last name55
text 1 wrote first name55 last name55
text 1 wrote first name55 last name55
text 1 wrote name55 surname55
+7 999 888-44-33 Nick
here user wrote Nick
here user wrote Nick
+7 999 888-22-11 First name Last name
and here First name Last name wrote
and here First name Last name wrote
+7 999 888-77-66 SuperNick
Super Nick too wrote
+7 999 888-77-66 Nikkkkk
well and nikkkkk
+7 999 888-66-55 first name55 last name55
text 2 wrote first name55 last name55
text 2 wrote first name55 last name55
+7 999 888-22-11 First name Last name
here text 2 from Last name first name
here text 2 from Last name first name
here text 2 from Last name first name
+7 999 888-77-66 SomeoneFromChat about
20 minutes ago something with wires
+ 7 999 888-22-11 First name Last name TraLa lal
lal
+7 999 888-77-66
SomeoneFromChat here FirstnameLastname again wrote 4 how to delete all messages from the user "+7 999 888-66-55" using a regular expression?

Using a regular expression is planned in sed (linux, bash)

PS all matches with real phone numbers are random and the names are fictitious. If the number, first name or last name belongs to you, please contact, the text will be changed

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Stalker_RED, 2020-07-14
@Free0wl

It’s quite simple with a regular expression
(\+7 999 888-66-55[\s\S]+?)(?=\n\+\d+ \d{3})
https://regex101.com/r/KlccLI/1/
But sed has its own dialect, in fact it’s not just a regular expression, you can write your own scripts there. And I still haven't mastered their syntax (.

M
m4xD, 2020-07-19
@m4xxD

It's elementary.
sed '/awk/d' filename.txt

K
ky0, 2020-07-14
@ky0

This is a task, not a question. Smoke seda manuals, check at regex101.com.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question