With the ^
and $
characters, we can express what the beginning, or the end will look like. As an example, let’s try sorting out content that starts with just hello.
/^hello/
This sample text won’t match anything because it doesn’t start with hello.
hello! this example will match.
Another example that will capture the text between that begins with hello and ends with goodbye;
/^hello(.+)goodbye$/
hello these places will be caught goodbye