-2

I'm struggling a couple of hours already. I can't do regex and never could.

I need to capture the file name, size, type, user, group, access, modified and created with preg_match (PHP) for later usage.

I know it's simple. I just can't do it. Any help will be appreciated.

Here's a screenshot of what I need to have captured (highlighted)

And an example string:

  File: '/home/user/file.php'
  Size: 23283       Blocks: 48         IO Block: 4096   regular file
Device: 801h/2049d  Inode: 967703      Links: 1
Access: (0600/-rw-------)  Uid: ( 1002/user)   Gid: ( 1003/user)
Access: 2022-06-06 07:12:31.298324852 -0400
Modify: 2022-06-02 07:54:24.493383727 -0400
Change: 2022-06-02 07:54:43.548316545 -0400
 Birth: 2022-06-02 07:12:31.298324852 -0400

P.S. Yes I WILL take care of my regex lacking knowledge. I'm ashamed of this. Just it's not the time right now.

tenev
  • 1
  • 1

1 Answers1

-1

Done thanks to my colleague: https://regex101.com/r/uQgVHk/2

(?:File: '(?P<File>.*)')\s+(?:Size: (?P<Size>[\d]+)).*(?:IO Block: [\d\s]+(?P<Type>[\w ]+))\s+.*\s+(?:Access: (?P<Permissions>\([\w\/ \-]+\)))\s+(?:Uid: \(\s*[\d\s]+\/\s*(?P<User>[\w]+)\))\s+(?:Gid: \(\s*[\d]+\/\s*(?P<Group>[\w]+)\)).*\s+.*\s+.*\s+(?:Change: (?P<Change>[\w\- \:\.]+))\s+(?:Birth: (?P<Birth>[\w\- \:\.]+))
tenev
  • 1
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 25 '22 at 13:02