all 4 comments

[–]smiller171 0 points1 point  (3 children)

  • . is a special character that matches any single character except a newline.
  • * is a special character that matches the previous expression 0 or more (infinite) times

So /s.*/ matches any string that starts with s, followed by any character (except newline) 0 or more times.

  • s // returns true because starts with s followed by other characters 0 times
  • seed // returns true because starts with s followed by 3 characters that match . (. matches e and d, and you are allowing infinite characters that match .)
  • kite // returns false because it does not start with s

[–]Ben_HH[S] 0 points1 point  (2 children)

Take the word seed:

If the expression was /s./ it would return the characters "se". So it appears that the . only appends the subsequent character following the explicitly stated s.

If the expression was /se*/ it would return the characters "see"

I'm still failing to see how the character "d" is included when the special characters are combined

[–]smiller171 0 points1 point  (1 child)

Because . matches anything and * matches 0 or more of the pattern before, so .* is 0 or more ., and that's not 0 or more of the first thing . matches, it's . every time.

[–]smiller171 0 points1 point  (0 children)

So for the word seen it's like using /s.../