|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Substr of a regular expression
I am currently using this code to auto link any http://www.hyperlinks.com/
PHP Code:
I want to make sure the \\n component between the <a></a> tags is truncated to a maximum of 30 chars. How can I use substr (or other) in this instance? |
|
#2
|
||||
|
||||
|
Yeah, but it takes a little bit more work.
Here's one way of doing it: PHP Code:
The #e flag means the replacement text is actually PHP code to be evaluated. (I made a small change or two to the expression) And you should use the onclick event instead of sticking JavaScript in the href. Code:
<a href="#" onclick="URLcheck('\2');">
__________________
FUMOFFURU! -- PHP Manual (cURL - PCRE regex - references) error_reporting() SQL injection: and mysql_real_escape_string() PHP and cron Negative0 Have spare time? Interested in a large-scale freelance PHP project? Chance for a part-time gig? PM me for details. |
|
#3
|
|||
|
|||
|
For reference, this is the code I am currently using.
PHP Code:
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > PHP Development > Substr of a regular expression |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|