RsD0p9BK
7/10/2013 - 2:12 PM

регулярные выражения

регулярные выражения

Regular expression to match style=“whatever:0; morestuff:1; otherstuff:3”

style="([^"]*)"

http://stackoverflow.com/questions/4101659/regular-expression-to-match-style-whatever0-morestuff1-otherstuff3
/*
As per author's request - added explanation:

preg_match(param1, param2, param3) is a function that allows you to match a single case scenario of a regular expression that you're looking for

param1 = "/^.+?](.+?)$/is"

"//" is what you put on the outside of your regular expression in param1

the i at the end represents case insensitive (it doesn't care if your letters are 'a' or 'A')

s - allows your script to go over multiple lines

^ - start the check from the beginning of the string

$ - go all the way to end of the string

. - represents any character

.+ - at least one or more characters of anything

.+? - at least one more more characters of anything until you reach

.+?] - at least one or more characters of anything until you reach ] (there is a backslash before ] because it represents something in regular expressions - look it up)

(.+)$ - capture everything after ] and store it as a seperate element in the array defined in param3

param2 = the string that you created.

I tried to simplify the explanations, I might be off, but I think I'm right for the most part.

*/
// убрать все знаки после точки включая точку?
preg_replace('/\..+$/','',$str);
preg_match("/^.+?\](.+)$/is" , $string_text, $match);
echo trim($match[1]);