/    Sign up×
Community /Pin to ProfileBookmark

bug in the regular expression

Hello people

I would like to use regular expression to check if a string contains the definition of background-image:url(<file>.png) attribute

that is in the following strings the attribute will be found:
style=”background-image: url(‘test.png’)”
style=”background-image: url(‘/Folder/test.png’)”
style=”background-image: url(‘./folder/Test.png’)”

I tried the following but it doesn’t work:

[code=php]
preg_match_all(‘/background-image:s*url(‘(.*.png)’);/Uis’,$s, $matches);
[/code]

However count($matches[0]) is always zero

can anyone see what is wrong with the regular expression, or maybe something is wrong in my examples

thanks

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsNov 24.2004 — try this:[code=php]preg_match_all("/((background)(\-image)?\:)s*url\((.+)\)\;?/i", $subject, $match, PREG_SET_ORDER);[/code]the url would be in $match[x][4]
Copy linkTweet thisAlerts:
@jasongrauthorNov 24.2004 — this is an interesting solution

thanks
×

Success!

Help @jasongr spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...