Re: Linking with regular expressions
| From: | Cynic | Date: | Sat, 23 Dec 2000 15:33:34 +0000 |
| Subject: | Re: Linking with regular expressions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-31680@lists.php.net to get a copy of this message | ||
what about this?
$s = "aaa aaa [xxxx xxx|zzzz] ccccc" ;
$r = '<a href="http://www.mysite.com/mypage.php?\\2">\\1</a>'
;
$p = '/\[(.*)\|(.*)\]/Us' ;
preg_replace( $p , $r , $s ) ;
produces:
aaa aaa <a href="http://www.mysite.com/mypage.php? zzzz ">xxxx
xxx</a> ccccc
At 15:54 23.12. 2000, Anton Permykov wrote the following:
--------------------------------------------------------------
>After trying again and again it seems I just don't understand regular
>expressions as well as I wish to, so maybe someone more experienced could
>help out.
>
>I want to convert every "[some text here|link]" (without quotes) into <a
>href="http://www.mysite.com/mypage.php?link">some
>text here</a>
>
>Maybe someone can help me with writing a pattern for this?
>
>Thank you,
>Anton.
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
>For additional commands, e-mail: php-general-help@lists.php.net
>To contact the list administrators, e-mail: php-list-admin@lists.php.net
------end of quote------
____________________________________________________________
Cynic:
A member of a group of ancient Greek philosophers who taught
that virtue constitutes happiness and that self control is
the essential part of virtue.
cynic@mail.cz