/    Sign up×
Community /Pin to ProfileBookmark

i am trying to get [Model# VDK 10-3] this but failed can some one help me

[code=php]
$dt=”[Model# VDK 10-3]; Straight Pop Up Promotional Counter with Graphics. Includes: 1 x Curve Popup Frame;
12 Magnetic Vertical Bars; 12 Magnetic Horizontal Bars; Black Counter Top. 1 x Soft Carry Case.”;

$data[]=$dt;

$numbers = array();
foreach($data as $entry)
{
if(preg_match_all(‘/^[^a-zA-Z{5}.A-Z{3}.0-9{2}0-9{1}]/’, $entry, $matches))
{
$numbers[] = $matches[0];
}
}

echo “<pre>” . print_r($numbers, true) . “</pre>”;
[/code]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@blue-eye-labsAug 07.2010 — [CODE]
[(.+)];
[/CODE]


That will get "[Model# VDK 10-3];" or anything else surrounded by square brackets and terminated by a semi-colon.
Copy linkTweet thisAlerts:
@experts585authorAug 07.2010 — hi

could you please explain me this pattern

please

i am thankful to you
Copy linkTweet thisAlerts:
@blue-eye-labsAug 07.2010 — The square parentheses ("[" and "]") are control characters in regex, so you have to escape them (thus the "[" and "]"). The full-stop (".") represents any character, and the addition operator ("+") says that we have one or more of them.

I suggest you look at a regex cheat sheet to help you along (e.g. at http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/) and also use a live regex tester (e.g. http://regexpal.com/).
×

Success!

Help @experts585 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 4.30,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...