G
G
GilbertAmethyst2020-02-09 19:46:53
Regular Expressions
GilbertAmethyst, 2020-02-09 19:46:53

How to write a regular expression to cut out extra text?

Hello!

I have a log like this:

27527 php /var/www/html/worker/Worker.php 3256 1581264072
27726 php /var/www/html/src/Controller/../../worker/Worker.php 3847


There are two types of lines here:
27726 php /var/www/html/src/Controller/../../worker/Worker.php 3847
and
27527 php /var/www/html/worker/Worker.php 3256 1581264072

I need cut the 4 digit ID from all row types (in bold), and delete the rest:
27726 php /var/www/html/src/Controller/../../worker/Worker.php 3847
and
27527 php /var/www/ html/worker/Worker.php 3256 1581264072

To end up with a log like this:
3847
3256
...


How can I write a regular expression for this task?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2020-02-09
@GilbertAmethyst

https://regex101.com/r/69tjgA/1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question