Can some body explain the difference between below expressions please?
[0-9]{1,3}:[0-5][0-9]
^([0-9]{1,3}:[0-5][0-9])$
I don't get the exact usage of ^ sign and $ sign in regular expressions.
I observe that If I write the second expression as below, it didn't make any difference.
^([0-9]{1,3}):([0-5][0-9])$
examples explain it clear:
^ : matches the beginning of a line
$ : matches the end of a line
"^foo$" : matches "foo", but not " foo" or "xxfooyy"
"foo$" : matches "foo", " foo" or "xxfoo" but not "foobar"
"^foo" : matches "foo", "fooyy" or "foo " but not "xfoo"
"foo" : matches "foo", " foo" or "xxfooyy"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With