PutterPlace Posted February 12, 2008 Share Posted February 12, 2008 I was given a regex pattern by a friend. I would like to know exactly what this pattern is looking for. I'm not very good at interpreting these. Here is the pattern given to me: ^\s*OK\s*\|\s*([a-f0-9]+)\s*\|\s*([a-f0-9]+)\s*$ I removed the beginning and trailing quotes because they aren't necessary at this point. Link to comment https://forums.phpfreaks.com/topic/90640-regex-pattern/ Share on other sites More sharing options...
effigy Posted February 12, 2008 Share Posted February 12, 2008 NODE EXPLANATION ---------------------------------------------------------------------- ^ the beginning of the string ---------------------------------------------------------------------- \s* whitespace (\n, \r, \t, \f, and " ") (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- OK 'OK' ---------------------------------------------------------------------- \s* whitespace (\n, \r, \t, \f, and " ") (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- \| '|' ---------------------------------------------------------------------- \s* whitespace (\n, \r, \t, \f, and " ") (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- [a-f0-9]+ any character of: 'a' to 'f', '0' to '9' (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- \s* whitespace (\n, \r, \t, \f, and " ") (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- \| '|' ---------------------------------------------------------------------- \s* whitespace (\n, \r, \t, \f, and " ") (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- ( group and capture to \2: ---------------------------------------------------------------------- [a-f0-9]+ any character of: 'a' to 'f', '0' to '9' (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- ) end of \2 ---------------------------------------------------------------------- \s* whitespace (\n, \r, \t, \f, and " ") (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- $ before an optional \n, and the end of the string Link to comment https://forums.phpfreaks.com/topic/90640-regex-pattern/#findComment-464934 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.