I'm trying to match users from an old DOS dump so they can be migrated to something new. They begin with a % sign and end with a ]. Some on one line and others across many lines.
https://regex101.com/r/0h5ndW/1
My Regex %([^\%]*)] works, but is there a better way to select each user beginning from % to the ] (including the % and ]) so I can put them through preg_replace and manipulate them later?
I'm a little skeptical about the multi line part.
Expected Output
%user:100 [ type=admin, added=10/12/1997, last-login:10/20/1997, total-logins:45, status:1 ]
%user:111 [ type=user, added=10/12/1997, last-login:10/27/1997, total-logins:145, status:1 ]
%user:112 [ type=viewer, added=10/12/1997, last-login:10/23/1997, total-logins:6, status:1 ]
%user:113 [ type=viewer, added=10/12/1997, last-login:10/14/1997, total-logins:2, status:1]
%user:114 [ type=viewer, added=10/12/1997, last-login:10/14/1997, total-logins:1, status:1]
%user:115 [ type=viewer, added=10/12/1997, last-login:10/12/1997, total-logins:1, status:1 ]
Raw Data
%user:100 [
type=admin,
added=10/12/1997,
last-login:10/20/1997,
total-logins:45,
status:1
]
%user:111 [
type=user,
added=10/12/1997,
last-login:10/27/1997,
total-logins:145,
status:1
]
%user:112 [ type=viewer, added=10/12/1997,
last-login:10/23/1997,
total-logins:6,
status:1
]
%user:113 [ type=viewer, added=10/12/1997, last-login:10/14/1997, total-logins:2, status:1]
%user:114 [ type=viewer, added=10/12/1997, last-login:10/14/1997, total-logins:1,
status:1]
%user:115 [ type=viewer, added=10/12/1997, last-login:10/12/1997, total-logins:1,
status:1
]