using regex
I just want to match strings containing https
or http
at the beginning and then finishing with \n
.
I have tried:
http|https(.*?)\n
but it seems not to work. What should I do?
Many thanks,
James
CodePudding user response:
No need to match individual http and https words. Actually, you can just perform or |
on what is the next possible character. Here, I'm assuming you would accept either s
as in https
or :
as in http:
. Any other character wouldn't be matched e.g. httpz
or http
.
http[s:].*\n
Or if the newline shouldn't be matched:
http[s:].*$
CodePudding user response:
What should I do?
You might use non-capturing groups as follows
(?:http|https)(.*?)\n