Regex: Ending with a specific thing

Viewed 133

I am trying to find an expression that begins with Hello and ends in one of two ways: with nothing after the "Hello", or if it has something else after it needs to be preceded with "//". After the //, anything goes.

I tried: grep '^Hello(//.*)?$' but this does not work.
There is something wrong with the last part: (//.*)?$

Sample Input:
Hello
Hello blah
Hi
Hello //
Hello // blah blah
Hello //blah

Sample Output using egrep:
Hello
Hello //
Hello // blah blah
Hello //blah
4 Answers
Related