Post
#1
|
|
|
Grupa: Zarejestrowani Postów: 208 Pomógł: 0 Dołączył: 19.04.2003 Ostrzeżenie: (0%)
|
Nie wiem czy da się coś takiego zrobić, a jeżeli się da... to jak? (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)
Mam string: Kod attrib1='jakis tekst'"```', attrib2 = "jakis " text'", attrib3 =`'tekst"jakis`, attrib4= '''''' I chciałbym uzyskać taką tablicę:Kod Array Jest to wykonalne?
( [0] => Array ( [0] => attrib1 [1] => attrib2 [2] => attrib3 [3] => attrib4 ) [1] => Array ( [0] => jakis tekst'"``` [1] => jakis " text' [2] => 'tekst"jakis [3] => '''' ) ) |
|
|
|
![]() |
Post
#2
|
|
|
Grupa: Zarejestrowani Postów: 208 Pomógł: 0 Dołączył: 19.04.2003 Ostrzeżenie: (0%)
|
Dobra, mam coś takiego (regExp znalazłem na kochanym php.net (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg) -- troszkę zmodyfikowałem):[php:1:40b820874b]<pre><?php
$str = 'attrName="attrV"alue2", attrName=attrValue2, attrName='attr'Value3', atrybut ="w|'''sc" '; $regexp = '/([a-zA-Z0-9]+)( )?=( )?((')|"|)((?(IMG:http://forum.php.pl/style_emoticons/default/sad.gif) ?:4)|(?(3)[^']|[^"]))*)(4)(?:s|,|$)/U'; preg_match_all( $regexp, $str, $matches, PREG_SET_ORDER ); print_r( $matches ); ?></pre>[/php:1:40b820874b]I mam taki wynik: Kod Array Tylko, co teraz dodać do tego regExp-a, żebym mógł też używać ` wraz z ' oraz " :?: 8O
( [0] => Array ( [0] => attrName="attrV"alue2", [1] => attrName [2] => [3] => [4] => " [5] => [6] => attrV"alue2 [7] => " ) [1] => Array ( [0] => attrName=attrValue2, [1] => attrName [2] => [3] => [4] => [5] => [6] => attrValue2 [7] => ) [2] => Array ( [0] => attrName='attr'Value3', [1] => attrName [2] => [3] => [4] => ' [5] => ' [6] => attr'Value3 [7] => ' ) [3] => Array ( [0] => atrybut ="w|'''sc" [1] => atrybut [2] => [3] => [4] => " [5] => [6] => w|'''sc [7] => " ) ) |
|
|
|
Wankster [RegularExpressions]+(Pobieranie danych) 18.09.2003, 21:06:10
FiDO Tak. Pomoze w tym napewno preg_match_all. 18.09.2003, 21:23:52
Wankster Wiem, że do tego trzeba użyć funkcji preg_match_al... 18.09.2003, 21:24:58
bamboos Witam!
moze:
'/(atrib[d+]) *= *('[^,]*',|"[^,]*",)... 18.09.2003, 22:09:32
adwol Re: [RegularExpressions]+(Pobieranie danych) 18.09.2003, 22:22:36 ![]() ![]() |
|
Aktualny czas: 25.12.2025 - 20:32 |