Skip to content

Instantly share code, notes, and snippets.

@egyjs
Last active April 5, 2024 05:31
Show Gist options
  • Save egyjs/9df1987563d35ac099ac27d3f7c97c52 to your computer and use it in GitHub Desktop.
Save egyjs/9df1987563d35ac099ac27d3f7c97c52 to your computer and use it in GitHub Desktop.
[laravel asset function] how to auto replace SRC,HREF with Laravel function using regex

This is the best I have so far using regex:

Find:

<((?!\s*((a)\s+))\w+)(.*?)((?:src|href)\s*=\s*")((?!\{\{\s*)[^"]+)"

Replace with:

<$1$4$5{{ asset('$6') }}"

have a lock at: https://regex101.com/r/PvIqTF/4

screenshot : screenshot of find and replace in PHPstorm

@lordjoo
Copy link

lordjoo commented Apr 10, 2021

Great Work Tanks bro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment