简体   繁体   中英

Getting filename between multipal special characters using Regex

I'm trying to fetch the file names which are in between multiple special character like '$$' ( example $$yaktocat.png$$) , i think it's better to ignore single special character $, if not we cannot use that character inside the file.

sample data

img src="$$yaktocat.png$$" alt="this is yaktocat image"

Regex trying to use

(\$+?(.*?)\$+?)

but still that match the single instance also

Do:

\$\$([^$]*)\$\$

Now the only captured group, ([^$]*) , will have the desired filename (eg yaktocat.png ), surrounded by $$ s.

Demo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM