regex to find js links

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

regex to find js links

Post by klevis miho »

I need a regular expression to find javascript links in a given webpage.
jimmy patel
Forum Newbie
Posts: 3
Joined: Sun May 16, 2010 12:14 am

Re: regex to find js links

Post by jimmy patel »

This expression may help you in finding src js files in given html code

Code: Select all

preg_match_all(~<\s*script[^>]+src=[\"\'](.*?)[\"\'][^>]+>~im, $html_source_code, $Arr_MatchJs);

MoonRose Infotech
w: http://www.moonroseinfotech.com
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Re: regex to find js links

Post by klevis miho »

thnx man
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Re: regex to find js links

Post by klevis miho »

This didnt work for me :(.

This yes: #<script[\s]+type=[\'\"]text/javascript[\'\"][\s]+src=[\'\"](.+?)[\'\"]></script>#s
but it is missing something
Post Reply