Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> szablonik
maggot
post 27.10.2002, 15:11:52
Post #1





Grupa: Zarejestrowani
Postów: 77
Pomógł: 0
Dołączył: 7.05.2002
Skąd: Sz-n/Wroc/Wawa

Ostrzeżenie: (0%)
-----


Kod
$szablon = '<table width=400>

<tr>

    <td><font size=1 color=gray>||R1||</font> - <B>||strtoupper(R2)||</B></td>

</tr>

<tr>

    <td style="text-align: justify"><font face=verdana size=2><DD>||formatuj(R3)||</td>

</tr>

<tr>

    <td align=right><a href="mailto:||R5||">||R4||</a></td>

</tr>

</table>'


napisalem sobie taki szablonik i chcialbym zeby sie wykonywal
tzn. R* zamienial na odpowiednie zmienne (tu problemu nie ma),
ale chcialbym zeby wykonywal tez odpowiednie funkcje np.
||strtoupper(R2)|| niech w to miejsce wstawi odpowiednia zmienna przetworzana przez funkcje 'strtoupper'

probuje cos kombinowac ze eregi_replace i eval ale mi nie wychodzi.
moze mi ktos pomoc


--------------------
/maggot/
Go to the top of the page
+Quote Post
kurtz
post 27.10.2002, 17:12:50
Post #2





Grupa: Przyjaciele php.pl
Postów: 786
Pomógł: 0
Dołączył: 18.03.2002
Skąd: Wroclaw/Warszawa

Ostrzeżenie: (0%)
-----


Cytat
ale chcialbym zeby wykonywal tez odpowiednie funkcje np.
||strtoupper(R2)|| niech w to miejsce wstawi odpowiednia zmienna przetworzana przez funkcje 'strtoupper'

preg_replace z modyfikatorem /e.

jesli chcesz zrobic sam to wystarczy tyle wiedziec ;)


--------------------
.. make web your home ..
Go to the top of the page
+Quote Post
Seth
post 27.10.2002, 17:14:47
Post #3





Grupa: Przyjaciele php.pl
Postów: 2 335
Pomógł: 6
Dołączył: 7.03.2002

Ostrzeżenie: (0%)
-----


Polecam gotowy skrypt wzorcow: smarty.php.net

P.S. thx hyper winksmiley.jpg
Go to the top of the page
+Quote Post
kurtz
post 27.10.2002, 17:19:00
Post #4





Grupa: Przyjaciele php.pl
Postów: 786
Pomógł: 0
Dołączył: 18.03.2002
Skąd: Wroclaw/Warszawa

Ostrzeżenie: (0%)
-----


Cytat
Polecam gotowy skrypt wzorcow: smarty.php.net

1. nie skrypt, a mechanizm
2. nie jestem pewny czy jest potrzebny. maggot najwyrazniej tworzy cos na wlasne potrzeby. nie potrzeba miec zawsze pod reka bazooki zeby zabic muche ;)


--------------------
.. make web your home ..
Go to the top of the page
+Quote Post
Seth
post 27.10.2002, 19:47:19
Post #5





Grupa: Przyjaciele php.pl
Postów: 2 335
Pomógł: 6
Dołączył: 7.03.2002

Ostrzeżenie: (0%)
-----


Zabijajac muche bazuka masz pewnosc, ze zginela (metafora)
Go to the top of the page
+Quote Post
maggot
post 27.10.2002, 19:50:46
Post #6





Grupa: Zarejestrowani
Postów: 77
Pomógł: 0
Dołączył: 7.05.2002
Skąd: Sz-n/Wroc/Wawa

Ostrzeżenie: (0%)
-----


Cytat
preg_replace z modyfikatorem /e.

jesli chcesz zrobic sam to wystarczy tyle wiedziec winksmiley.jpg


nie bede sie upieral zeby to robic samemu tongue.gif

jak ktos wie to niech napisze, albo poda jakis wyczerpujacy (z wieloma przykladami) artykul o wyrazeniach regulanych


--------------------
/maggot/
Go to the top of the page
+Quote Post
Seth
post 27.10.2002, 20:49:03
Post #7





Grupa: Przyjaciele php.pl
Postów: 2 335
Pomógł: 6
Dołączył: 7.03.2002

Ostrzeżenie: (0%)
-----


Cytat
I must've read 50 regular expression tutorials and understood nothing from each. I finally worked them out through playing around and looking at other people's examples. I wrote this to summarise and clarify things. I find it helps as a quick lookup reference:

^ Start of String
$ End of string

n* Zero or more of 'n'
n+ One or more of 'n'
n? A possible 'n'

n{2} Exactly two of 'n'
n{2,} At least 2 or more of 'n'
n{2,4} From 2 to 4 of 'n'

() Parenthesis to group expressions
(n|a) Either 'n' or 'a'

. Any single character

[1-6] A number between 1 and 6
[c-h] A lower case character between c and h
[D-M] An upper case character between D and M
[^a-z] Absence of lower case a to z
[_a-zA-Z] An underscore or any letter of the alphabet

^.{2}[a-z]{1,2}_?[0-9]*([1-6]|[a-f])[^1-9]{2}a+$

A string beginning with any two characters
Followed by either 1 or 2 lower case alphabet letters
Followed by an optional underscore
Followed by zero or more digits
Followed by either a number between 1 and 6 or a character between a and f (Lowercase)
Followed by a two characters which are not digits between 1 and 9
Followed by one or more n characters at the end of a string
 
 
jolyon at mways dot co dot uk
03-Feb-2002 09:43  
 
The postcode example listed here isn't correct - it won't correctly detect Inner London postcodes (and others?) with an extra letter, eg:  

EC1M 3AA  

I've also ammended it so that the space is optional:  

if(eregi('^[A-Z]{1,2}[0-9]{1,2}[A-Z]? ?[0-9][A-Z]{2}$',$postcode)  
{  
print "You have a valid postcode!";  
}


Jak znajde wiecej to podesle.
Go to the top of the page
+Quote Post
kurtz
post 27.10.2002, 21:05:17
Post #8





Grupa: Przyjaciele php.pl
Postów: 786
Pomógł: 0
Dołączył: 18.03.2002
Skąd: Wroclaw/Warszawa

Ostrzeżenie: (0%)
-----


Cytat
Cytat

preg_replace z modyfikatorem /e.

jesli chcesz zrobic sam to wystarczy tyle wiedziec ;)


nie bede sie upieral zeby to robic samemu :P

a moze chociaz sprobujesz? leniom nie pomagam. papa

Cytat
jak ktos wie to niech napisze, albo poda jakis wyczerpujacy (z wieloma przykladami) artykul o wyrazeniach regulanych

rusz dupcie i sam sobie znajdz.


--------------------
.. make web your home ..
Go to the top of the page
+Quote Post
kurtz
post 27.10.2002, 21:06:35
Post #9





Grupa: Przyjaciele php.pl
Postów: 786
Pomógł: 0
Dołączył: 18.03.2002
Skąd: Wroclaw/Warszawa

Ostrzeżenie: (0%)
-----


Cytat
Cytat
I must've read 5...

a nie lepiej poswiecic chwile i po prsotu przeczytac perldoc perlre ?


--------------------
.. make web your home ..
Go to the top of the page
+Quote Post
Seth
post 27.10.2002, 22:27:07
Post #10





Grupa: Przyjaciele php.pl
Postów: 2 335
Pomógł: 6
Dołączył: 7.03.2002

Ostrzeżenie: (0%)
-----


Ten cytat znalazlem w komentarzach bodajze do funkcji eregi(). Niestety wiekszosco osob wogole ich nie czyta, a to wg. mnie jest bledem smile.gif

Maggot: poszukaj o wyrazeniach regularnych na zend.com i wdvl.com tam napewno cos bedzie bo swojego czasu przeszedlem przez ten temat wzdluz i wszerz tongue.gif i na tych stronach bylo wiele do czytania... oj wiele rolleyes.gif
Go to the top of the page
+Quote Post
maggot
post 27.10.2002, 23:23:45
Post #11





Grupa: Zarejestrowani
Postów: 77
Pomógł: 0
Dołączył: 7.05.2002
Skąd: Sz-n/Wroc/Wawa

Ostrzeżenie: (0%)
-----


doszedlem do czegosc takiego:

Kod
preg_replace("/||([_a-zA-Z]+).(.+)||/e", "eval('echo 1("2");')", $c);


i prawie dziala, tylko nie wiem czemu ten przetworzony tekst pojawia sie na poczatku, a nie w odpowiednim miejscu w szablonie


--------------------
/maggot/
Go to the top of the page
+Quote Post
dragossani
post 30.12.2002, 14:02:40
Post #12





Grupa: Przyjaciele php.pl
Postów: 398
Pomógł: 0
Dołączył: --
Skąd: Poznań

Ostrzeżenie: (0%)
-----


Zgadzam się z Seth'em w sprawie Smarty. Lepiej mieć zawsze pod ręką bazookę w razie jakby za muchą czaiło się coś większego. :wink: Pojawią się jakieś zmiany w projekcie, nagle okaże się, że potrzebne są dodatkowe rozwiązania (czyli za muchą czaił się niedźwiedź) i bazooka jak znalazł. biggrin.gif


--------------------
cease this long, long rest / wake and risk a foul weakness to live / when it all comes down / watch the smoke and bury the past again / sit and think what will come / raise your fears and cast them all away
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 24.06.2025 - 23:58