I would like to find if a string contains a regular expression that starts and ends with a hash (#) and contains colon (:). All those should be matched on the same line
Example: hello to #some:test# and george MATCH
Example: hello to #:# world NO MATCH
Example: hello to #test:# world NO MATCH
Example: hello #:test# world NO MATCH
Example:
hello [newline]
to #some:test# world NO MATCH
Thanks,
Yannis
This should do:
Breakdown:
Note that
.will match any character and is probably not the most efficient regular expression.A non greedy version (more efficient):