On Mar 19, 2022, at 7:17 PM, William Torrez Corea <[email protected]> wrote:
>
> Here is the short code:
>
> https://gist.github.com/adipasquale/2217595
>
The regular expression in that program is not valid. You are using brackets […]
incorrectly. The pattern [a-z] will match exactly one character in the range
a-z. The pattern [a-z\/\.] will match one character in the range a-z or the
backslash character ‘\’ or the forward slash character’/‘ or the period
character ‘.’. Inside brackets you do not need to escape special characters,
and if you want to match the ‘-‘ character, put it at the beginning or ending
of the pattern string, e.g. [a-z-] will match a-z or ‘-‘.
Here is a regular expression that should do what you want:
while ( /(https?:\/\/\S*?\.jpg)/g ) {
Here is another one that uses the m{} operator so you don’t have to escape the
‘/‘ characters and the /x modifier to allow you to insert whitespace and
comments into the regular expression to make it more readable:
while ( m{ ( https?:// \S*? .jpg ) }xg ) {
Either of these finds 47 links to .jpg files in your data document:
https://scontent.fmga3-1.fna.fbcdn.net/v/t39.30808-1/274490608_3202483196693292_7724900589789523726_n.jpg
...
Jim Gibson
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/