Hello.
Well, I found this piece of code on php.net. Thats fine but where can i find
explanation for all these ("|\')?([^ "\']*)("|\')?.*>([^<]*)' syntax so that
I can construct my own rules for all kind of eregi preg and oter match
functions ?
Transform HTML links into plain-text "links" with the URL visible
function AHREF2text($str ing) {
return eregi_replace(' <A .*HREF=("|\')?([^ "\']*)("|\')?.*>([^<]*)</A>',
'[\\4] (link: \\2)', $string);
} 6 2590
And another simple question, maybe its the same answer.
whats the syntax of eregi_replace if I want to match ( remove in this
case ) few strings, not one:
eregi_replace (("stringone" && "stringtwo" ), "", $source)
Or it just requires whole eregi expression each time ?
This ofcourse doesn't work but hope you know what I mean.
lecichy wrote: And another simple question, maybe its the same answer. whats the syntax of eregi_replace?
You better switch to preg_ functions. They're faster and more powerful
than ereg*
if I want to match ( remove in this case ) few strings, not one: eregi_replac e (("stringone" && "stringtwo" ), "", $source)
Try
<?php
$destin = preg_replace('/string(?:one|tw o)/i', '', $source)
?>
/string(?:one|tw o)/i -- means:
/ # start of regex
string # match "string literally"
(?: # start a group but don't grab (no need for that)
one # literal "one"
| # OR
two # literal "two"
) # end group
/i # end regex, but match without regard to case
see the preg_ function at http://pt.php.net/manual/en/ref.pcre.php
Also try regex-coach from http://weitz.de/regex-coach/
using the PCRE_EXTENDED modifier (x) you can put the regex and
the comments in the source file
<?php
function AHREF2text($str ing) {
return preg_replace(
'@ # start of regex
<a[ ] # literal "<a " (notice the space)
[^<]* # any number of (any characters EXCEPT "<")
href= # literal "href="
("|\')? # optional double OR single quote (grabbed)
([^"\']*) # any number of (anything BUT double
## OR single quote) (grabbed)
("|\')? # optional double OR single quote (grabbed)
[^>]* # any number of (any characters EXCEPT ">") # a literal ">"
([^<]*) # any number of anything BUT "<" (grabbed)
</a> # literal "</a>"
@ix', # end regex, caseless and extended
'[\\4] (link: \\2)', $string);
}
// =============== ==============
$x = 'At <a href="http://mysite.example. com/">my site</a> there
are many <a href="http://examples.exampl e.com/">examples</a> :)';
echo $x, '<hr />', htmlentities($x ), '<hr />', AHREF2text($x);
?>
--
I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded.
lecichy wrote: Thank you so much Pedro!
You're welcome lecichy.
Hope you enjoy regex's and the power they give you.
--
I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded. You're welcome lecichy. Hope you enjoy regex's and the power they give you.
-- I have a spam filter working. To mail me include "urkxvq" (with or without the quotes) in the subject line, or your mail will be ruthlessly discarded.
Enjoy what ?
Just kidding :P
Now I'm so powerful that even my mom is afraid to come to my room ;)
lecichy wrote: Now I'm so powerful that even my mom is afraid to come to my room ;)
Moms have more power than all the regex gurus put together!
--
I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: steve |
last post by:
I am quite frustrated with php’s include, as I have spent a ton of
time on it already... anyone can tell me why it was designed like this
(or something I don’t get)?
The path in include is relative NOT to the immediate script that is
including it, but is relative to the top-level calling script.
In practice, this means that you have to constantly worry and adjust
paths in includes, based on the startup scripts that call these...
|
by: Nuno Paquete |
last post by:
Hi group.
I'm using this code to see if is there any parameter for variable "menu":
if($_GET == "downloads")
....
But this code log errors if there is no parameter passed (this heappens at
the first time the page is loaded).
I tryed this code:
|
by: Average_Joe |
last post by:
Hello PHP people,
Was wondering if PHP5 had some sort of "nested class" functionality.
I'm trying to figure out how to return an object (with a private
constructor) that has access to variables in another class.
Something like:
$obj = $factory->getObject("1234");
|
by: David Furey |
last post by:
Hi
I have an XML documnet and a XSLT document as shown below
THe XSLT document brings back a filtered docmument that has the VendorName
that starts with a particular sub-string
This works as expected with alphabet and number characters and the ' (single
quote ' entity) character but does not work if a double quote character
" is part of the string to filter on
This returns all Vendor Names that begin with A (either case)
|
by: NecroJoe |
last post by:
I am using PHP to generate a little javascript for one of my pages. In
short it allows a user to select a value from a list and pop it into a form
field on a seperate page. This works well unless there is a " or ' in the
character string.
<SCRIPT language=JavaScript>
function Add_Term(SearchTerm) {
window.opener.document.advsearch.name_title.value +=
SearchTerm;
window.close();
| |
by: Mateusz Loskot |
last post by:
Hi,
I'd like to ask how XML parsers should handle attributes which consists
of " entity as value. I know XML allows to use both: single and
double quotes as attribute value terminator. That's clear.
But how should parser react for such situation:
I have CORDSYS element with string attribute which consists of value
with many " entities:
|
by: Arpi Jakab |
last post by:
I have a main project that depends on projects A and B. The main project's
additional include directories list is:
...\ProjectA\Dist\Include
...\ProjectB\Dist\Include
Each of the include directories contain a file named "cppfile1.h".
In my main project I #include "cppfile1.h". I rely on the order of paths in
additional include directories list to get file cppfile1.h from ProjectA and
|
by: martin |
last post by:
Hi,
I would be extremly grateful for some help on producing an xml fragemt.
The fragment that I wish to produce should look like this
<Addresses>
<Address>&qout;Somebody's Name" <me@mydomain.com></Address>
</Addresses>
|
by: manchin2 |
last post by:
Hi,
Can anybody please provide the information about """ and its use, if possible please provide an example.
1)<tm:bom-expression>{Conf.getEquityConfLookupFields().getEventFieldText("AdditionalDisruption","Change in Law")}</tm:bom-expression>
2)07:41:08 Default ( call ( . ( call ( . Conf getEquityConfLookupFields ) ) getEventFieldText ) ( , AdditionalDisruption Change inLaw ) ) value=Not applicable
Can you please...
|
by: fran7 |
last post by:
Hi, from help in the javascript forum I found the error in some code but need help. This bit of code works perfectly, trouble is I am writing it to a javascript function so the height needs to be in "" instead of "" otherwise I get an error message.
Can anyone suggest how to write it so that it writes " instead of "".
I have tried all combinations of adding " to the code but as soon as I think I am there I get throw out again.
if...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |