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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.