Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> szablonik
maggot
post
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
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Seth
post
Post #2





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

Posty w temacie


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

 



RSS Aktualny czas: 26.12.2025 - 03:49